- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page