[Bug c++/85861] g++ -Wconversion misses int to size_t

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 23 16:51:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85861

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
My guess is that we don't want to warn about conversions that are well-defined
and the original value can be obtained by a round-trip. Converting a size_t to
an int is lossy, i.e. converting back to size_t may not give the original
value. But converting an int to size_t and back to an int is value preserving.

So I can see why it makes sense to have different warnings for lossy and
non-lossy conversions.


More information about the Gcc-bugs mailing list