This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: enums and null pointer constants
- To: zack at wolery dot cumb dot org
- Subject: Re: enums and null pointer constants
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Mon, 22 May 00 18:22:11 EDT
- Cc: gcc at gcc dot gnu dot org
An integer constant expression with the value 0, or such an
expression cast to type void *, is called a null pointer constant.
also section 6.6 para 6:
An /integer constant expression/ shall have integer type and
shall only have operands that are integer constants,
*enumeration constants*, character constants, sizeof expressions
whose results are integer constants, and floating constants
that are the immediate operands of casts.
// = italics in standard, ** = my emphasis.
Taken together, I believe this means that an enum with value 0 is to
be considered a null pointer constant, so the comment and the build1
operation are incorrect.
I disagree. It clearly says an integer constant expression shall
have integer type. It is only its *operand* that can be enumeration
constants. The expression itself cannot have an enumeration type.