This is the mail archive of the gcc@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]

Re: Why is this code accepted?


> Cc: Mike Stump <mrs@windriver.com>, gcc@gcc.gnu.org
> From: Alexandre Oliva <aoliva@redhat.com>
> Date: 17 Apr 2001 18:51:45 -0300

> On Apr 17, 2001, nbecker@fred.net wrote:

> > If it doesn't work shouldn't gcc reject it?

Oh, wait, I know what's wrong...

g++  -pedantic-errors -ansi -S t.cc
t.cc:13: ISO C++ forbids initialization of member constant `a' of non-integral 
   type `const double[]'

It works as designed, and if we add:

const double X::a[2];

to the program to meet the logical requirements of the extension, and
don't ask for the error, then it works as expected.  I was thinking
of a language without the clause:

4 If a  static data member is of  const integral or   const  enumeration
  type,  its  declaration  in  the  class  definition  can  specify  a
  constant-initializer which shall be an  integral  constant  expression
  (5.19).   In  that  case,  the  member can appear in integral constant
  expressions within its scope.  The member shall still be defined in  a  |
  namespace  scope  if it is used in the program and the namespace scope  |
  definition shall not contain an  initializer.

in it, sorry for the confusion.  This wording first appeared in the 95
(95-0029) version of the working paper, so it is new...  :-)

So, no, no extension was broken, and no, no bug is present.


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