This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Non-constant expression allowed to dimension array declarations
- To: gcc at gcc dot gnu dot org, rittle at latour dot rsch dot comm dot mot dot com
- Subject: Re: Non-constant expression allowed to dimension array declarations
- From: mike stump <mrs at windriver dot com>
- Date: Thu, 28 Jun 2001 13:17:04 -0700 (PDT)
- Cc: rodney dot leadbeater at convergys dot com
> Date: Thu, 28 Jun 2001 04:46:09 -0500 (CDT)
> From: Loren James Rittle <rittle@latour.rsch.comm.mot.com>
> To: gcc@gcc.gnu.org
> Cc: rodney.leadbeater@convergys.com
> In article <41FBBB1B17AFD4119ECE000347088836F5A917@wbnsmail.gtl.com> you write:
> > I was amazed to see that gcc allows the following. [...]
> I am amazed that people fail to read the manual. ;-)
Heck, that's nothing, I was amazed he wasn't familiar the the C
standard:
5. The following is a block scope declaration of a
typedef name A with a variable length array type.
void tdef(int n)
{
typedef int A[n];
A a;
A *p;
p = &a;
}
6.5.5.2 Array declarators
Constraints
[#1] The [ and ] may delimit an expression or *. If [ and ]
delimit an expression (which specifies the size of an
array), it shall have an integer type. If the expression is
a constant expression then it shall have a value greater
than zero. The element type shall not be an incomplete or
function type.
[#2] Only ordinary identifiers (as defined in 6.1.2.3) with
block scope or function prototype scope and without linkage
can have a variably modified type. If an identifier is
declared to be an object with static storage duration, it
shall not have a variable length array type.