This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compiler bug?


On Tue, Apr 08, 2003 at 09:22:28AM -0300, Alexandre Oliva wrote:
> On Apr  8, 2003, Nathan Myers <ncm-nospam at cantrip dot org> wrote:
> 
> >   bug.cc: In instantiation of `Outer<char>::Inner':
> >   bug.cc:14:   instantiated from here
> >   bug.cc:12: `sizeof' applied to incomplete type `Outer<char>::Inner'
> 
> > Outer<>::Inner doesn't look incomplete to me. 
> 
> There's no such thing as flexible array members in C++.  An earlier
> draft of the C99 Standard said:
> 
>        A structure type containing a flexible array member is an
>        incomplete type that cannot be completed.  [6.2.5]/23
> 
> but this statement is gone from the final version.  This was probably
> done to address the incompatibility that would arise between sizeof
> being well-defined for structs with flexible array members
> [6.7.2.1]/17, and the requirement that the expression given to sizeof
> doesn't have an incomplete type [6.5.3.4]/1 (hmm...  how about to the
> incomplete type itself?)
> 
> For short: looks like a bug to me.  Compliance with (parts of) the
> draft but not the final standard.

Hm, I didn't think C99 had static members.  Here's a simpler case:

  template<typename T> 
    struct Foo
    {
        int c;
        static int s[];
    };

  template<typename T>
    int Foo<T>::s[sizeof(Foo<T>)];

  int* p = Foo<char>::s;

Nathan Myers
ncm-nospam at cantrip dot org


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