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*
694 Discussions

[re again] icx (2022.2.1.20221020) optimization bug

tmichio3
Beginner
790 Views

I want to do the process of cutting off the code at the end of the string.

The if part in the list below is omitted.(-O1 and -O2)

I want to switch from icc to icx, but I can't do it with this.

ps.

  a. Does not occur in version (2021.4.0.20210924).

  b. Please also fix the fact that the -finline option does not work with -O0.

 

 

・string.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>

int main(void)
{
char string[]={"Language ,1\n"};
char *buffer = malloc(1024 * 3);
char *label,*data;
int len;
char delims[2];

strcpy(buffer,string);

// divide into tokens
delims[0]=',';
delims[1]='\0';
if(NULL==(label=strtok(buffer, delims))) return -6;
if(NULL==(data =strtok(NULL, delims))) return -5;

len = strlen(data);
if(data[len - 1] == '\n') data[len - 1] = '\0';  // <= omit

printf("[%s]\n",label);
printf("[%s]\n",data);
return 0;
}

・icx abnomal

>:~/user$ icx -O2 string.c -o string
>:~/user$ ./string  (result)
[Language ]
[1      <- line feed remains
]  

 

・icc (and gcc)  is correct

>:~/user$ icc -O2 string.c -o string -diag-disable=1044
>:~/user$ ./string      (result)
[Language ]
[1]

0 Kudos
2 Replies
ShivaniK_Intel
Moderator
769 Views

Hi,


Thanks for posting in the Intel forums.


Thanks for reporting this issue. We were able to reproduce it on our end and we have informed the development team about it.


Thanks & Regards

Shivani


0 Kudos
ShivaniK_Intel
Moderator
443 Views

Hi,


Thank you for your patience. The issue raised by you has been fixed in the 2023.1 version which will be released in the coming months. If the issue still persists with the new release, then you can start a new discussion for the community to investigate.


Thanks & Regards

Shivani


0 Kudos
Reply