I can't disagree with your reading ("involve" doesn't mean "be").  However,
searching for "integral constant expression" suggests to me that this
outlaws the following code, all of which compiles without warning:

enum {dim = 1};
char a [dim]; // 8.3.4.1
void* b = new char [1] [dim]; // 5.3.4.6
struct Badger
{
  static const int i = dim; // 9.4.2.4
};

-----Original Message-----
From: Martin v. Loewis [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 24, 2001 9:09 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED];
debian-gcc@lists.debian.org; [EMAIL PROTECTED]
Subject: Re: comparing function pointer with int does not produce error


> > I'll take another attempt at declaring gcc behaviour to be correct.
> > According to 4.10/1, "success" is a null pointer constant:
> > 
> > # A null pointer constant is an integral constant expression (5.19)
> > # rvalue of integer type that evaluates to zero. A null pointer
> > # constant can be converted to a pointer type; the result is the null
> > # pointer value of that type and is distinguishable from every other
> > # value of pointer to object or pointer to function type.
> > 
> > 5.19/1 defines "integral constant expressions":
> > 
> > # An integral constant-expression can involve only literals (2.13),
> > # enumerators, const variables or static data members of integral or
> > # enumeration types initialized with constant expressions (8.5),
> > # non-type template parameters of integral or enumeration types, and
> > # sizeof expressions.
> 
> Then why does the following NOT compile:
> 
> void stat ();
> enum {success};
> void monk ()
> {
>   if (stat == success);
> }
> 
> cbool.cpp:6: no match for `void (&)() == <anonymous enum>' operator
> 
> As success is an enumerator which is a integral constant-expression by
your
> definition above; it also has zero value and thus must be a "null pointer
> constant" and hence the comparisom should be allowed (however distasteful
> that may be).

In this code, "success" does not have integer type. 3.9.1/7 specifies

# Types bool, char, wchar_t, and the signed and unsigned integer types
# are collectively called integral types. A synonym for integral type
# is integer type.

Since a null pointer constant must be of integer type, "success" does
not qualify. Change it to "(int)success", and it compiles.

Regards,
Martin


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


Reply via email to