This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/57359] wrong code for union access at -O3 on x86_64-linux


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)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]