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]
Other format: [Raw text]

Re: Variable-sized types vs. templates


>A key difference between the two is that GNU C dynamic arrays can exist inside
>a structure, and VLAs can not.  This means GNU C has variable sized types,
>but ISO C99 does not.  Variable sized types complicates things like argument
>passing, so it is understandable that ISO C99 left this out.  I can also see
>that it complicates stuff like template instantiation, so it would make sense
>to leave this out of the C++ language also.

I was a little too hasty here.  ISO C99 has VLAs, and VLAs are obviously
variable sized types.  What I meant to say was that ISO C99 can never have
an argument with a variable sized type.  Arrays decay to pointers when used
as arguments, and VLAs aren't allowed inside structures, so there is no way
to get a variable sized argument in ISO C99.  There isn't any other place in C
where variable sized types are a problem.  There are other places in C++, but
the VLA rules may be enough to avoid all problems.

GNU C dynamic arrays can be used to create variable sized arguments.  The
Ada language can also have variable sized arguments, and the GNU C dynamic
arrays feature can be useful for testing support needed for Ada.

Jim


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