Intel® oneAPI Data Parallel C++
Support for Intel® oneAPI DPC++ Compiler, Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and GDB*
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
420 Discussions

[re again] icx (2022.2.1.20221020) optimization bug

tmichio3
Beginner
337 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
1 Reply
ShivaniK_Intel
Moderator
316 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


Reply