public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-21664-4@http.gcc.gnu.org/bugzilla/>]
* [Bug c/21664] New: array-of-empty-structure extension not properly defined
@ 2005-05-19 14:02 rguenth at gcc dot gnu dot org
2005-05-19 19:55 ` [Bug c/21664] " gdr at integrable-solutions dot net
2005-05-19 20:20 ` rguenth at gcc dot gnu dot org
0 siblings, 2 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-05-19 14:02 UTC (permalink / raw)
To: gcc-bugs
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? Should the C-frontend rather emit
return 0;
? Of course this contradicts the C standard, but that does not
allow empty structures anyway.
--
Summary: array-of-empty-structure extension not properly defined
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21664
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/21664] array-of-empty-structure extension not properly defined
2005-05-19 14:02 [Bug c/21664] New: " rguenth at gcc dot gnu dot org
@ 2005-05-19 19:55 ` gdr at integrable-solutions dot net
2005-05-19 20:20 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 5+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-05-19 19:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2005-05-19 19:45 -------
Subject: Re: New: array-of-empty-structure extension not properly defined
"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
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21664
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/21664] array-of-empty-structure extension not properly defined
2005-05-19 14:02 [Bug c/21664] New: " rguenth at gcc dot gnu dot org
2005-05-19 19:55 ` [Bug c/21664] " gdr at integrable-solutions dot net
@ 2005-05-19 20:20 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-05-19 20:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-05-19 20:20 -------
None. But I have to deal with the possibilities of these during folding
of &a[2] == &a[1]. At least until the middle-end makes a promise that
they cannot exist (which they do), or the C frontend rejects this. It's
really a question for advice on details of our own extension to the C language.
Richard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21664
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-18 20:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-21664-10053@http.gcc.gnu.org/bugzilla/>
2005-10-25 19:47 ` [Bug c/21664] array-of-empty-structure extension not properly defined pinskia at gcc dot gnu dot org
[not found] <bug-21664-4@http.gcc.gnu.org/bugzilla/>
2014-03-20 7:27 ` mpolacek at gcc dot gnu.org
2014-04-18 20:57 ` mpolacek at gcc dot gnu.org
2005-05-19 14:02 [Bug c/21664] New: " rguenth at gcc dot gnu dot org
2005-05-19 19:55 ` [Bug c/21664] " gdr at integrable-solutions dot net
2005-05-19 20:20 ` rguenth at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).