- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My code:
#include <stdio.h>
int dd, dm, dy, i;
char s[32], d[5];
FILE *file;
int main() {
file = fopen("d.txt", "r");
for(i=0; i<5; i++) {
fgets(s, 30, file);
d[0]=s[0];
d[1]=s[1];
d[2]=0;
dd=atoi(d);
d[0]=s[3];
d[1]=s[4];
d[2]=0;
dm=atoi(d);
d[0]=s[6];
d[1]=s[7];
d[2]=s[8];
d[3]=s[9];
d[4]=0;
dy=atoi(d);
printf("%i %i %i %s", dd, dm, dy, s);
}
fclose(file);
}
Compiling with O1 option:
1 9 1995 01.09.1995
4 9 1995 04.09.1995
5 9 1995 05.09.1995
6 9 1995 06.09.1995
7 9 1995 07.09.1995
Compiling with O2 or O3 option:
0 9 1995 01.09.1995
995 9 1995 04.09.1995
995 9 1995 05.09.1995
995 9 1995 06.09.1995
995 9 1995 07.09.1995
WTF?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I submitted this bug to the development team (reference number DPD200365574). You can workaround the problem by compiling with -O1 or with -O2 -unroll=0 (but this turns off loop unrolling for the entire file, you can turn of unrolling for individual loops with #nounroll see this page for info: https://software.intel.com/en-us/node/524556). Thanks for reporting this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue is fixed in 15.0 Update 3.
$ icc -V test.c
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.3.187 Build 20150407
Copyright (C) 1985-2015 Intel Corporation. All rights reserved.
Edison Design Group C/C++ Front End, version 4.8 (Apr 8 2015 01:33:53)
Copyright 1988-2013 Edison Design Group, Inc.
GNU ld version 2.20.51.0.2-5.36.el6 20100205
$ ./a.out
1 9 1995 01.09.1995
4 9 1995 04.09.1995
5 9 1995 05.09.1995
6 9 1995 06.09.1995
7 9 1995 07.09.1995

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