Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Bug in icc 2015.1.148???

$
0
0

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?

 


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>