This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix 11614
On 22 Jul 2003 20:15:35 +0200, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> Jason Merrill <jason@redhat.com> writes:
>
> | Yep. From C99:
> |
> | As a special case, the last element of a structure
> | with more than one named member may have an incomplete array
> | type. This is called a flexible array member...
>
> Humm, however, that sort of conflicts with C++:
>
> typedef int ary_t[];
>
> makes ary_t denote an incomplete type,
Yes.
> therefore
>
> struct { ary_t s; };
>
> should be ill-formed.
That's ill-formed only because it doesn't declare anything.
struct A { ary_t s; };
is fine because s is a flexible array member. Under the C99 rules, you
just can't create an object of type struct A.
> 3.9/6
>
> A class that has been declared but not defined, or an array of
> unknown size or of incomplete element type, is an
> incompletely-defined object type.38) Incompletely-defined object
> types and the void types are incomplete types (3.9.1). Objects
> shall not be defined to have an incomplete type.
Obviously the use of any C99 features in C++ is an extension which is not
reflected in the C++ standard.
Jason