https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71803
Bug ID: 71803
Summary: Wpedantic: enumerator value is not an integer constant
expression
Product: gcc
Version: 6.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: johan at forberg dot se
Target Milestone: ---
This concerns GCC 6.1.1 running on Arch Linux amd64. The following code will
produce a warning if compiled with -Wpedantic:
enum { TEST = 1 << 31 };
The warning is:
warning: enumerator value for ‘TEST’ is not an integer constant expression
[-Wpedantic]
But if I instead write
enum { TEST = 1 << 30 };
There is no warning.
This is unforunate since e.g. the glib/gio headers contain such enums, so they
will add warnings to the compile if using -Wpedantic.
I don't feel that this warning is motivated. According to the C11 standard
(final draft, page 106), an integer constant expression "shall have integer
type and shall only have operands that are integer constants", which by my
understanding this expression satisfies.
Thanks for you attention,
Johan