Incorrect warning
Bjorn Pettersen
bjorn@roguewave.com
Wed Jun 7 16:36:00 GMT 2000
I've discovered an incorrect warning about using enumerations in array
new expressions when compiling with -Wall -pedantic.
The following code:
int* f() {
enum {s=10};
int* b = new int[s];
return b;
}
Gives the following warning:
warning: size in array new must have integral type
Section 5.3.4 of the standard defines direct-new-declarator as:
direct-new-declarator:
[ expression ]
direct-new-declarator [ constant-expression ]
and, 5.19.1 goes on to say
An integral constant-expression can involve only literals
(lex.literal), enumerators, const ...
gcc -v gives:
gcc version 2.95.2 19991024 (release)
Sincerely,
Bjorn Pettersen
Tech Lead, Tools.h++
Rogue Wave Software, Inc.
More information about the Gcc-bugs
mailing list