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

            Bug ID: 84764
           Summary: Wrong warning "so large that it is unsigned" for
                    __int128 constant
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pascal_cuoq at hotmail dot com
  Target Milestone: ---

According to the output of the following program, the type of the constant
10000000000000000000 is __int128, which is a signed type:

Compiler Explorer link: https://godbolt.org/g/kFTNaz

#include <stdio.h>

#define prtype(X)                                                 \
  _Generic((X),                                                   \
           int: "int",                                            \
           long: "long",                                          \
           long long: "long long",                                \
           unsigned int: "unsigned int",                          \
           unsigned long: "unsigned long",                        \
           unsigned long long: "unsigned long long",              \
           __int128: "__int128",                                  \
  default: "?")

int main(void) {
  printf("1 %s\n", prtype(1));
  printf("3000000000 %s\n", prtype(3000000000));
  printf("10000000000000000000 %s\n", prtype(10000000000000000000));
}

___
Output:

1 int
3000000000 long
10000000000000000000 __int128

However a warning is emitted on the last line for the constant
10000000000000000000:

prtype.c:17:66: warning: integer constant is so large that it is unsigned

This warning implies that the constant is typed as long long, which has been
the case either historically or with other -std= settings. However, for the
compilation settings at hand, the warning is wrong. It should at most say that
the constant is typed with a type outside of the "int, long, long long"
hierarchy of standard types.

For reference the relevant clause of the C11 standard is 6.4.4:
https://port70.net/~nsz/c/c11/n1570.html#6.4.4

Reply via email to