On Tue, Mar 24, 2009 at 10:46 AM, Dave Korn
<[email protected]> wrote:
> Brian Ellis wrote:
>> struct dynamic { int size; int array[]; };
>
>> int main() { struct dynamic * pBadness = ((struct dynamic *) malloc(
>> sizeof(int) * 3) );
>
>> dont_do_this( *pBadness );
>
>
> Are you even allowed to dereference a pointer to a struct containing a VLA?
> Should it be treated like an incomplete type in this respect?
>
gcc.c-torture/compile/pr16566-2.c has
---
struct A
{
int i;
int x[];
};
int foo(struct A a)
{
return (a,a).x[0];
}
---
foo will return a random number. I don't think it should be allowed.
H.J.