This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug c/21664] New: array-of-empty-structure extension not properly defined
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc-bugzilla at gcc dot gnu dot org
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 19 May 2005 22:45:58 +0200
- Subject: Re: [Bug c/21664] New: array-of-empty-structure extension not properly defined
- References: <20050519140009.21664.rguenth@gcc.gnu.org>
"rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| For
|
| struct {} a[4]; int main() { return &a[2] - &a[1]; }
|
| the C frontend emits
|
| return 0 /[ex] 0;
|
| which will, at -O0 fault at runtime, at -O not due to RTL CSE.
|
| Is this even well-defined?
No, as you noted below.
| Should the C-frontend rather emit
|
| return 0;
|
| ? Of course this contradicts the C standard, but that does not
| allow empty structures anyway.
If you go back to the GCC mailing list (circa 2001, 2002), you'll see
heavy and hot debates about what the answer should be.
For that matter, the C++ standards allow empty structures but do not
allow "return 0". I suppose the real question is what use do you have
for an array of empty structures.
-- Gaby