This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
possible pedantic bug
- To: gcc-bugs at gcc dot gnu dot org
- Subject: possible pedantic bug
- From: "Jeff Bouis" <j_bouis at hotmail dot com>
- Date: Tue, 25 Apr 2000 20:23:13 PDT
The following code:
enum { FOO = 3 };
int main()
{
int* arr = new int[FOO];
return 0;
}
when compiled with the "-pedantic" option will produce the warning
"warning: size in array new must have integral type"
This has been tested with version 2.95 under Solaris 2.6, and also with the
nightly snapshot validator at http://www.codesourcery.com/gcc-compile.html.
Replacing FOO with a number (such as 3) in the first line of main() will
compile without warnings.
It is complaining that FOO is not an integral type. While that is true, the
Standard C++ specification seems clear that a conversion from the
enumeration to an integral type should happen automatically and implicitly
[cf. sections 4 (especially 4.3 and 4.5) and 7.2]. For example, the line
int bar = FOO;
compiles without any warnings. The warning above only occurs when
allocating a dynamic array, yet after a careful reading of section 5.3.4 I
cannot find any reason that the implicit conversion/promotion should not
occur when using new.
Thanks for your time.
Jeff Bouis
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com