This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Incorrect warning


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]