public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96875] New: Aliased pointers to union members result in different output with optimisation level.
@ 2020-08-31 18:20 iains at gcc dot gnu.org
2020-08-31 18:23 ` [Bug target/96875] " iains at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2020-08-31 18:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96875
Bug ID: 96875
Summary: Aliased pointers to union members result in different
output with optimisation level.
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: iains at gcc dot gnu.org
Target Milestone: ---
For my 0.02 GBP this is ill-conditioned code, but apparently either the try is
still out - or it has been decided to consider it OK.
struct s1 { double d; };
struct s2 { double d; };
union u { struct s1 x; struct s2 y; };
__attribute__((__noinline__))
double
f(struct s1 *a, struct s2 *b)
{
a->d = 1.0;
return b->d + 1.0;
}
int
main ()
{
union u X;
return f (&X.x, &X.y) == 2.0;
}
====
O1:
f:
.LFB0:
.cfi_startproc
fmov d0, 1.0e+0
str d0, [x0]
ldr d1, [x1]
fadd d0, d1, d0
ret
.cfi_endproc
this is the "expected" result.
=====
O2:
f:
.LFB0:
.cfi_startproc
ldr d1, [x1]
fmov d0, 1.0e+0
str d0, [x0]
fadd d0, d1, d0
ret
.cfi_endproc
this is some random answer.
====
I'd hazard a guess that something decides that pointers to different types
can't alias, so it's OK to move things around... but the user code bends over
backwards to force the different entities to alias.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/96875] Aliased pointers to union members result in different output with optimisation level.
2020-08-31 18:20 [Bug target/96875] New: Aliased pointers to union members result in different output with optimisation level iains at gcc dot gnu.org
@ 2020-08-31 18:23 ` iains at gcc dot gnu.org
2020-08-31 18:24 ` pinskia at gcc dot gnu.org
2020-08-31 18:26 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: iains at gcc dot gnu.org @ 2020-08-31 18:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96875
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |aarch64-linux-gnu,
| |aarch64-darwin
Ever confirmed|0 |1
CC| |fxcoudert at gcc dot gnu.org,
| |rsandifo at redhat dot com
Keywords| |alias
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-08-31
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/96875] Aliased pointers to union members result in different output with optimisation level.
2020-08-31 18:20 [Bug target/96875] New: Aliased pointers to union members result in different output with optimisation level iains at gcc dot gnu.org
2020-08-31 18:23 ` [Bug target/96875] " iains at gcc dot gnu.org
@ 2020-08-31 18:24 ` pinskia at gcc dot gnu.org
2020-08-31 18:26 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-08-31 18:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96875
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There is a defect report against the C standard about this case and a much
older gcc bugzilla filed too.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/96875] Aliased pointers to union members result in different output with optimisation level.
2020-08-31 18:20 [Bug target/96875] New: Aliased pointers to union members result in different output with optimisation level iains at gcc dot gnu.org
2020-08-31 18:23 ` [Bug target/96875] " iains at gcc dot gnu.org
2020-08-31 18:24 ` pinskia at gcc dot gnu.org
@ 2020-08-31 18:26 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-08-31 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96875
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is an exact dup of bug 14319
*** This bug has been marked as a duplicate of bug 14319 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-31 18:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 18:20 [Bug target/96875] New: Aliased pointers to union members result in different output with optimisation level iains at gcc dot gnu.org
2020-08-31 18:23 ` [Bug target/96875] " iains at gcc dot gnu.org
2020-08-31 18:24 ` pinskia at gcc dot gnu.org
2020-08-31 18:26 ` pinskia 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).