https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85861
--- Comment #13 from Jonny Grant <jg at jguk dot org> --- (In reply to Jonathan Wakely from comment #11) > 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. Do you mean because size_t is 64bit typically, and int is only 32bit? I tested this on my 64bit Ubuntu It converts a size_t 9,223,372,036,854,775,807 to an int and ends up with 18,446,744,073,709,551,615 Which I was surprised about, as I thought int was 4 bytes. I had expected 4,294,967,295 printf("size_t: %zu\n", sizeof(size_t)); printf("int: %zu\n", sizeof(int)); size_t big = 9223372036854775807; int smaller = big; size_t big2 = smaller; printf("smaller: %d, big2: %zu\n", smaller, big2); > So I can see why it makes sense to have different warnings for lossy and > non-lossy conversions. That sounds good, all lossy would be useful to have a loss of precision warning.