Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
33 Views

icc-16.0.3 not respecting fno-strict-overflow flag?

$ icc -v
icc version 16.0.3 (gcc version 4.8.0 compatibility)

$ cat b.c

void
foo(int fl) {
  long i;

  for (i = 0; i < fl + 1; i++) {
      printf("%d\n", i);
    }
}

$ cat main.c

#include <limits.h>
void foo(int fl);
int
main()
{
  foo(INT_MAX);
}

$ icc -m32 -O0 -fno-strict-overflow -falias -no-ansi-alias main.c b.c -o O0.out
$ icc -m32 -O2 -fno-strict-overflow -falias -no-ansi-alias main.c b.c -o O2.out

$ ./O0.out
<no output>
$ ./O2.out
0
1
2
...

For O2, icc seems to be incorrectly ignoring the -fno-strict-overflow flag in 32-bit mode.  The problem does not occur in 64-bit mode.

We are wondering if we should expect -fno-strict-overflow flag to work correctly with icc or not?

0 Kudos
2 Replies
Highlighted
Black Belt
33 Views

I don't see any evidence of icc supporting this strict-overflow option.

Remember that long should be interpreted as int64_t for 64-bit mode linux, but int32_t for 32-bit mode or Windows.  icc has special treatments of int overflow for 32-bit mode which I haven't seen explained adequately and would hope not to rely on (in part by not expecting long to be very useful).

Apparently, the gcc options with respect to int overflow were put in for benefit of linux kernel, and icc compatibility may be exercised only in that context, if at all.  For all I know, Intel may have worked to eliminate such dependencies from kernel.

0 Kudos
Highlighted
Beginner
33 Views

Thanks, Tim.

0 Kudos