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

icx (2022.2.1.20221020) optimization bug

tmichio3
Beginner
313 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.

 

・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
261 Views

Hi,


Thanks for posting in the Intel forum.


Since this is a duplicate thread of

https://community.intel.com/t5/Intel-oneAPI-Data-Parallel-C/re-again-icx-2022-2-1-20221020-optimization-bug/m-p/1434189#M2660,

we will no longer monitor this thread. We will continue addressing this issue in the other thread.


Thanks & Regards

Shivani





0 Kudos
Reply