This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: enums and null pointer constants
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Subject: Re: enums and null pointer constants
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Mon, 22 May 2000 15:19:43 -0700
- Cc: gcc at gcc dot gnu dot org
- References: <10005222222.AA26050@vlsi1.ultra.nyu.edu>
On Mon, May 22, 2000 at 06:22:11PM -0400, Richard Kenner wrote:
> 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.
Ah, but an enumeration type _is_ an integer type. 6.2.5 para 17:
The type char, the signed and unsigned integer types, and the
enumerated types are collectively called integer types.
zw