Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

icx: data corruption at -O2

cmelone
Beginner
484 Views

I am building main.c (attached) with icx

 

Intel(R) oneAPI DPC++/C++ Compiler 2023.2.0 (2023.2.0.20230622)

 

The expected output of the program is "0 1 2 3 4 5 6 7." However, when compiled with -O2, the application returns incorrect data. We suspect that icx is reversing the loop at L22-L23 and this results in data corruption.

 

[cmelone@shepard-login-0-1 bug]$ icx -O1 main.c
[cmelone@shepard-login-0-1 bug]$ ./a.out
0 1 2 3 4 5 6 7 
[cmelone@shepard-login-0-1 bug]$ icx -O2 main.c
[cmelone@shepard-login-0-1 bug]$ ./a.out 
0 1 2 3 0 2 0 2.125

 

I am not able to reproduce this with icc.

0 Kudos
3 Replies
Alex_Y_Intel
Moderator
461 Views

Happens on oneAPI DPC++/C++ Compiler 2024.2 too, escalated the issue to our engineering team. 

0 Kudos
cw_intel
Moderator
434 Views

I reported the issue to our internal team. Will let you know when the issue is fixed.


Thanks,

Chen


0 Kudos
cw_intel
Moderator
190 Views

Hi,

This is not a bug. The test case is violating ansi-alias semantics by casting (double * a) into (float *) and hence has undefined behavior. To get the same results as -O1, you can compile the code with option '-fno-strict-aliasing'.


0 Kudos
Reply