Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7933 Discussions

icx error: wrong code at -O2 since `x86-64 icx 2022.2.0`

Junwei_Zeng
Beginner
638 Views

Hi,

I compiled the following code with icx at -O2, and it produces the wrong code. The correct output result should be 0, but 4 was output under -O2.
I found this bug was introduced starting from icx-2022.2.0.

Compiler explorer: https://godbolt.org/z/zvss3bKTn

 

$ cat test.c
int printf(const char *, ...);
long a, b, g;
int c, f;
short d;
static int *e = &c;
int main() {
  for (; a <= 4; a++) {
    b = 2;
    for (; b; b--) {
      d = 4;
      for (; d; d--) {
        *e = f;
        if (g)
          break;
      }
    }
  }
  printf("res = %d\n", d);
}
$
$ icx -O0 test.c; ./a.out
res = 0
$
$ icx -O2 test.c; ./a.out
res = 4
$
$ gcc-13 -O2 test.c; ./a.out
res = 0
$
$ icx --version
Intel(R) oneAPI DPC++/C++ Compiler 2023.2.0 (2023.2.0.20230622)
Target: x86_64-unknown-linux-gnu
$
$ gcc-13 --version
gcc (Compiler-Explorer-Build-gcc--binutils-2.40) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.

 

Best regards,

Junwei Zeng.

Labels (1)
0 Kudos
1 Solution
VaishnaviV_Intel
Moderator
395 Views

Hi,

 

Thank you for your patience. The issue raised by you has been targeted to be fixed in the Intel oneAPI 2024.1 version. Please download and let us know if this resolves your issue. We will be closing this thread from our side, If the issue still persists with new release then create a new thread for us to investigate. 

 

Thanks & Regards,

Vankudothu Vaishnavi.


View solution in original post

0 Kudos
4 Replies
VaishnaviV_Intel
Moderator
561 Views

Hi,


Thanks for posting on Intel communities.

We are working on your issue internally. We'll get back to you soon.


Thanks & Regards,

Vankudothu Vaishnavi.


0 Kudos
VaishnaviV_Intel
Moderator
495 Views

Hi,

 

Thanks for reporting this issue.

We were able to reproduce it and we have informed the development team about it. We'll get back to you soon.

 

Thanks & Regards,

Vankudothu Vaishnavi.


0 Kudos
VaishnaviV_Intel
Moderator
396 Views

Hi,

 

Thank you for your patience. The issue raised by you has been targeted to be fixed in the Intel oneAPI 2024.1 version. Please download and let us know if this resolves your issue. We will be closing this thread from our side, If the issue still persists with new release then create a new thread for us to investigate. 

 

Thanks & Regards,

Vankudothu Vaishnavi.


0 Kudos
Junwei_Zeng
Beginner
382 Views

Hi,

 

Thank you for your prompt reply and confirmation. It's great to hear that this issue has been targeted to be fixed in the Intel  oneAPI 2024.1 version.

 

Once the new version is available, I'll thoroughly test it to ensure the issue has been resolved. Should any concerns persist, I won't hesitate to reach out and seek further assistance from the community.

 

Again, thank you for your assistance in this matter.

 

Best regards,

Junwei Zeng.

0 Kudos
Reply