public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/59741] New: Union with struct with flexible array member output incorrectly
@ 2014-01-09 19:06 jakub at gcc dot gnu.org
2014-01-09 20:09 ` [Bug middle-end/59741] " jakub at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-09 19:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59741
Bug ID: 59741
Summary: Union with struct with flexible array member output
incorrectly
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
I believe this testcase will fail on -fsection-anchors targets (but haven't
verified other than eyeballing the assembly):
struct A { int a; char b[]; };
union B { struct A a; char b[sizeof (struct A) + 31]; };
union B b = { { 1, "123456789012345678901234567890" } };
union B c = { { 2, "123456789012345678901234567890" } };
__attribute__((noinline, noclone)) void
foo (int *x[2])
{
x[0] = &b.a.a;
x[1] = &c.a.a;
}
int
main ()
{
int *x[2];
foo (x);
if (*x[0] != 1 || *x[1] != 2)
__builtin_abort ();
return 0;
}
Even on x86_64-linux, one can see bogus assembly:
.type c, @object
.size c, 36
c:
.long 2
.string "123456789012345678901234567890"
.zero 32
.globl b
.align 16
.type b, @object
.size b, 36
b:
.long 1
.string "123456789012345678901234567890"
.zero 32
(note, .size is correct, but the actual data for the vars much larger than
that).
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/59741] Union with struct with flexible array member output incorrectly
2014-01-09 19:06 [Bug middle-end/59741] New: Union with struct with flexible array member output incorrectly jakub at gcc dot gnu.org
@ 2014-01-09 20:09 ` jakub at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-09 20:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59741
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Dup.
*** This bug has been marked as a duplicate of bug 28865 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-09 20:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-09 19:06 [Bug middle-end/59741] New: Union with struct with flexible array member output incorrectly jakub at gcc dot gnu.org
2014-01-09 20:09 ` [Bug middle-end/59741] " jakub at gcc dot gnu.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).