simple C++ program exhibits data corruption when compiled with -fstrict-aliasing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-4.8-armhf-cross (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
When cross-compiled using the command line:
$ arm-linux-
the attached program generates the incorrect output:
# clobbered_pair: 0x00000000, 0x00000000
# clobbered_pair: 0x88888888, 0x44444444
The correct output is:
# clobbered_pair: 0x00000000, 0x00000000
# clobbered_pair: 0x00000000, 0x00000000
This is produced as expected when compiling with:
$ arm-linux-
(Also, compiling to the native x86-64 architecture using g++-4.8 produces correct output using either optimization settings.)
The data from the ticks_t instance created on line 33 ends up overwriting the temporary pair_t() passed in the fourth argument to print_clobbered
(We have reduced the problem to the attached minimal test case from a much more complicated system. Details such as the seemingly unnecessary user-defined copy constructor of the struct ticks_t or the unused arguments of the function print_clobbered
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: g++-4.8-
ProcVersionSign
Uname: Linux 3.13.0-37-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.5
Architecture: amd64
CurrentDesktop: X-Cinnamon
Date: Mon Oct 20 15:15:20 2014
ProcEnviron:
TERM=xterm
PATH=(custom, no user)
XDG_RUNTIME_
LANG=en_GB.UTF-8
SHELL=/bin/bash
SourcePackage: gcc-4.8-armhf-cross
UpgradeStatus: No upgrade log present (probably fresh install)
I have re-submitted this bug report to the Linaro bug tracker: /bugs.linaro. org/show_ bug.cgi? id=933
https:/