3 ms·
That really seems like something that should generate warning, when a value assigned to a size_t was cast to a type smaller than size_t from a value that was as
by TapamN 4y ago
That really seems like something that should generate warning, when a value assigned to a size_t was cast to a type smaller than size_t from a value that was as >= size_t.
size_t v; //64-bit size_t
v = (unsigned)0xff00000001;
printf("%zu\n", v); //Prints 1
I don't get any warnings for this on GCC 9.4 or Clang 15.0.4 with Wall+Wextra.
If you wanted to deliberately do that kind of cast, for some reason, you could prevent the warning like this:
v = (size_t)(unsigned)0xff00000001;