This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Incorrect warning
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Incorrect warning
- From: Bjorn Pettersen <bjorn at roguewave dot com>
- Date: Wed, 07 Jun 2000 17:49:48 -0600
- CC: stdtools at roguewave dot com
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.