Re: What does zero-length array mean at file scope?

2009-05-29 Thread Andrew Haley
Joseph S. Myers wrote: > On Sun, 24 May 2009, Andrew Haley wrote: > >> Of course we have to fix the assembler output. For [any] two declarations >> a and b, &a != &b, even when a is a zero-length array. So, you have to >> allocate at least one byte. > > I don't think this is necessarily part of

Re: What does zero-length array mean at file scope?

2009-05-28 Thread Dave Korn
Joseph S. Myers wrote: > On Sun, 24 May 2009, Dave Korn wrote: > >> So, is the testcase invalid, and should the compiler be warning about this >> declaration? I couldn't get any complaint out of it even with "-W -Wall >> -Wextra -pedantic -std=c89"? Or should the linker be allocating some spac

Re: What does zero-length array mean at file scope?

2009-05-28 Thread Dave Korn
Joseph S. Myers wrote: > On Sun, 24 May 2009, Andrew Haley wrote: > >> Of course we have to fix the assembler output. For ant two declarations >> a and b, &a != &b, even when a is a zero-length array. So, you have to >> allocate at least one byte. > > I don't think this is necessarily part of t

Re: What does zero-length array mean at file scope?

2009-05-28 Thread Joseph S. Myers
On Sun, 24 May 2009, Andrew Haley wrote: > Of course we have to fix the assembler output. For ant two declarations > a and b, &a != &b, even when a is a zero-length array. So, you have to > allocate at least one byte. I don't think this is necessarily part of the semantics for the GNU extensio

Re: What does zero-length array mean at file scope?

2009-05-28 Thread Joseph S. Myers
On Sun, 24 May 2009, Dave Korn wrote: > So, is the testcase invalid, and should the compiler be warning about this > declaration? I couldn't get any complaint out of it even with "-W -Wall > -Wextra -pedantic -std=c89"? Or should the linker be allocating some space > for this zero-sized common

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Dave Korn
Andrew Haley wrote: >>> Obviously I can't see for looking; can you please point me to the precise >>> chapter/page/paragraph/line that I should have found earlier? > > "Zero-length arrays are allowed in GNU C. They are very useful as the > last element of a structure ..." > > That doesn't in

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Andrew Haley
Dave Korn wrote: > Dave Korn wrote: >> Dave Korn wrote: >>> I've read http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html about six >>> times and can't see anywhere it even hints that you can use this syntax >>> anywhere except as the trailing member of a struct. >> Andrew Haley wrote: >>> But zero-

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Dave Korn
Dave Korn wrote: > Dave Korn wrote: >> I've read http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html about six >> times and can't see anywhere it even hints that you can use this syntax >> anywhere except as the trailing member of a struct. > > Andrew Haley wrote: >> But zero-length arrays are a gc

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Dave Korn
Dave Korn wrote: > I've read http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html about six > times and can't see anywhere it even hints that you can use this syntax > anywhere except as the trailing member of a struct. Andrew Haley wrote: > But zero-length arrays are a gcc extension. There's nothi

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Andrew Haley
Dave Korn wrote: > Andrew Haley wrote: >> Dave Korn wrote: >>> Dave Korn wrote: Dave Korn wrote: > ELF GAS/LD seem happy enough when presented with a ".comm foo,0" > directive, but PE does rather literally what you asked, and gives you > no data object, leading to i0 in the ab

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Dave Korn
Andrew Haley wrote: > Dave Korn wrote: >> Dave Korn wrote: >>> Dave Korn wrote: >>> ELF GAS/LD seem happy enough when presented with a ".comm foo,0" directive, but PE does rather literally what you asked, and gives you no data object, leading to i0 in the above being an undefined >>

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Andrew Haley
Dave Korn wrote: > Dave Korn wrote: >> Dave Korn wrote: >> >>> ELF GAS/LD seem happy enough when presented with a ".comm foo,0" >>> directive, >>> but PE does rather literally what you asked, and gives you no data object, >>> leading to i0 in the above being an undefined reference at link time.

Re: What does zero-length array mean at file scope?

2009-05-24 Thread Uros Bizjak
Hello! I found something rather odd in testcase gcc.c-torture/execute/20030811-1.c: > /* Origin: PR target/11535 from H. J. Lu */ > > void vararg (int i, ...) > { > (void) i; > } > > int i0[0], i1; Huh? > void test1 (void) > { > int a = (int) (long long) __builtin_return_address

Re: What does zero-length array mean at file scope?

2009-05-23 Thread Dave Korn
Dave Korn wrote: > Dave Korn wrote: > >> ELF GAS/LD seem happy enough when presented with a ".comm foo,0" directive, >> but PE does rather literally what you asked, and gives you no data object, >> leading to i0 in the above being an undefined reference at link time. > > After a bit further d

Re: What does zero-length array mean at file scope?

2009-05-23 Thread Dave Korn
Dave Korn wrote: > ELF GAS/LD seem happy enough when presented with a ".comm foo,0" directive, > but PE does rather literally what you asked, and gives you no data object, > leading to i0 in the above being an undefined reference at link time. After a bit further digging, it turns out that th

What does zero-length array mean at file scope?

2009-05-23 Thread Dave Korn
Hi everyone, I found something rather odd in testcase gcc.c-torture/execute/20030811-1.c: > /* Origin: PR target/11535 from H. J. Lu */ > > void vararg (int i, ...) > { > (void) i; > } > > int i0[0], i1; Huh? > void test1 (void) > { > int a = (int) (long long) __builtin_return_a