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

            Bug ID: 88625
           Summary: c11: GCC Allows enumerator value not representable in
                    type int.
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anders.granlund.0 at gmail dot com
  Target Milestone: ---

Test case (prog.c):

  enum E { x = UINT_MAX };

  int main()
  {
  }

Compilation command line:

  gcc prog.c -Wall -Wextra -std=c11 -pedantic-errors

Observed behaviour:

  No error message outputed.

Expected behaviour:

  An error message outputed.

  The value of the integer constant expression UINT_MAX is not representable
  as an int. This is not allowed.

Reference to the c11 standard (the bugfix version of the c11 standard):

  6.7.2.2/2:

    "The expression that defines the value of an enumeration constant shall be
     an integer constant expression that has a value representable as an int."

Note:

  Clang gives the expected error.

Reply via email to