https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87129
Bug ID: 87129 Summary: -Wsign-conversion Erroneously Triggered When Dereferencing Pointer From Implicit User Conversion Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ian at geometrian dot com Target Milestone: --- When dereferencing a pointer created from calling an implicit user conversion, g++ erroneously produces a warning from -Wsign-conversion about (inexplicably) converting `size_t` into a signed integer type. If a pointer of the same type is used instead, (correctly) no warning is generated. Minimal sample: //Compile with `-Wsign-conversion` #include <cstdlib> //`size_t` extern float* data; struct Accessor { operator float*() { return data; } }; float foo(Accessor accessor, size_t i) { return accessor[i]; } Output (9.0.0 20180824 x86-64): <source>: In function 'float foo(Accessor, size_t)': <source>:13:20: warning: conversion to 'long int' from 'size_t' {aka 'long unsigned int'} may change the sign of the result [-Wsign-conversion] 13 | return accessor[i]; | ^ Tested as occurring in many versions of g++, from 9.0 back to at least 4.4.