[Bug c/96788] "integer constant is so large that it is unsigned" warning is incorrect

richard-gccbugzilla at metafoo dot co.uk gcc-bugzilla@gcc.gnu.org
Wed Aug 26 18:47:03 GMT 2020


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

--- Comment #3 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
In the mean time, what is GCC's intent here? Clang is following the behavior
described by GCC's diagnostic text, treating decimal integer literals that
don't fit in 'long long' but do fit in 'unsigned long long' as the latter type
(I've not checked back far enough to tell if this is what GCC ever actually
did, or if we got this by looking at the diagnostics and didn't check the
behavior). If that's not what GCC intends to do any more, that'd be useful for
us to know, and we can switch to following GCC's actual behavior. (It'd also
make sense to update the diagnostic text in that case!)

It looks like both the Clang behavior (treat the literal as 'unsigned long
long') and the GCC behavior (treat the literal as '__int128' where available
and 'long long' otherwise) are conforming extensions in both C and C++, even
though __int128 isn't (yet) an extended integer type: such a literal "has no
type" in C, which presumably results in undefined behavior, and makes the
program ill-formed in C++, so it seems there is room for a vendor extension in
both languages.


More information about the Gcc-bugs mailing list