This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/57359] wrong code for union access at -O3 on x86_64-linux
- From: "ch3root at openwall dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Oct 2017 15:59:48 +0000
- Subject: [Bug tree-optimization/57359] wrong code for union access at -O3 on x86_64-linux
- Auto-submitted: auto-generated
- References: <bug-57359-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57359
Alexander Cherepanov <ch3root at openwall dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ch3root at openwall dot com
--- Comment #12 from Alexander Cherepanov <ch3root at openwall dot com> ---
Still reproducible if the number of iterations is changed to 3.
I've also converted the testcase to allocated memory:
----------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
__attribute__((__noinline__,__noclone__))
void test(int *pi, long *pl, int k, int *pa)
{
for (int i = 0; i < 3; i++) {
pl[k] = // something that doesn't change but have to be calculated
*pa; // something that potentially can be changed by assignment to *pi
*pi = 0;
}
}
int main(void)
{
int *pi = malloc(10);
int a = 1;
test(pi, (void *)pi, 0, &a);
printf("%d\n", *pi);
}
----------------------------------------------------------------------
Results:
----------------------------------------------------------------------
$ gcc -std=c11 -pedantic -Wall -Wextra test.c && ./a.out
0
$ gcc -std=c11 -pedantic -Wall -Wextra -O3 test.c && ./a.out
1
----------------------------------------------------------------------
gcc version: gcc (GCC) 8.0.0 20171024 (experimental)