public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/84764] Wrong warning "so large that it is unsigned" for __int128 constant
       [not found] <bug-84764-4@http.gcc.gnu.org/bugzilla/>
@ 2023-01-25  9:45 ` daniel.lundin.mail at gmail dot com
  2023-01-25 10:36 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-25  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Lundin <daniel.lundin.mail at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.lundin.mail at gmail dot co
                   |                            |m

--- Comment #3 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
This is a bug as in the wrong text is displayed in the diagnostic message. gcc
picks `__int128` and it is not an unsigned type.

Decimal integer constants use the the quoted list in 6.4.4.1: `int` then `long`
then `long long`. Therefore this normative text (from C99 to C23) applies: "If
all of the types in the list for the constant are signed, the extended integer
type shall be signed."

gcc behaves just like required too, since `__int128` ought to be one of the
extended integer types and it is signed.

I would guess this message is some remain from C90 where extended integer types
didn't exist. Compiling with -std=c90 adds an additional warning "warning: this
decimal constant is unsigned only in ISO C90". It would appear that this is the
correct warning that should always be displayed. Seems to be a minor bug that
occurred during the switch (gcc 5.0.0) from gnu90 to gnu11 as default option.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/84764] Wrong warning "so large that it is unsigned" for __int128 constant
       [not found] <bug-84764-4@http.gcc.gnu.org/bugzilla/>
  2023-01-25  9:45 ` [Bug c/84764] Wrong warning "so large that it is unsigned" for __int128 constant daniel.lundin.mail at gmail dot com
@ 2023-01-25 10:36 ` redi at gcc dot gnu.org
  2023-01-26  1:26 ` joseph at codesourcery dot com
  2023-01-26  7:53 ` daniel.lundin.mail at gmail dot com
  3 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-25 10:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Daniel Lundin from comment #3)
> gcc behaves just like required too, since `__int128` ought to be one of the
> extended integer types and it is signed.

But it's not an extended integer type, see comment 2.

I think that will change for C23, which allows intmax_t to be be defined to
long long even if there are larger extended integer types. But in GCC today,
there are no extended integer types.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/84764] Wrong warning "so large that it is unsigned" for __int128 constant
       [not found] <bug-84764-4@http.gcc.gnu.org/bugzilla/>
  2023-01-25  9:45 ` [Bug c/84764] Wrong warning "so large that it is unsigned" for __int128 constant daniel.lundin.mail at gmail dot com
  2023-01-25 10:36 ` redi at gcc dot gnu.org
@ 2023-01-26  1:26 ` joseph at codesourcery dot com
  2023-01-26  7:53 ` daniel.lundin.mail at gmail dot com
  3 siblings, 0 replies; 4+ messages in thread
From: joseph at codesourcery dot com @ 2023-01-26  1:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Also, for it to become an extended integer type, it would be necessary to 
define integer constant suffixes and implement printf / scanf support in 
the library, because <stdint.h> is now required to provide intN_t / 
uintN_t when there is a matching standard or extended integer type, so 
would be required to provide int128_t / uint128_t, which in turn would 
require the corresponding <stdint.h> and <inttypes.h> macros, so requiring 
constant suffixes and printf / scanf support.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/84764] Wrong warning "so large that it is unsigned" for __int128 constant
       [not found] <bug-84764-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2023-01-26  1:26 ` joseph at codesourcery dot com
@ 2023-01-26  7:53 ` daniel.lundin.mail at gmail dot com
  3 siblings, 0 replies; 4+ messages in thread
From: daniel.lundin.mail at gmail dot com @ 2023-01-26  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Daniel Lundin <daniel.lundin.mail at gmail dot com> ---
Call it what you will, either way there is nothing here that's "so large that
it is unsigned". The main point is that the diagnostic message is wrong.

typeof(18446744073709551615) x = -1;

Gives a 128 bit integer type with the value -1. If it was "so large that it is
unsigned" then this would have resulted in an unsigned type with an unsigned
value. The diagnostic message is plain wrong and misleading.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-26  7:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-84764-4@http.gcc.gnu.org/bugzilla/>
2023-01-25  9:45 ` [Bug c/84764] Wrong warning "so large that it is unsigned" for __int128 constant daniel.lundin.mail at gmail dot com
2023-01-25 10:36 ` redi at gcc dot gnu.org
2023-01-26  1:26 ` joseph at codesourcery dot com
2023-01-26  7:53 ` daniel.lundin.mail at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).