This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bug in Intel V7 Linux compiler?
- From: Peter Barada <peter at baradas dot org>
- To: GATMKORN at aol dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 9 Feb 2003 10:21:04 -0500 (EST)
- Subject: Re: bug in Intel V7 Linux compiler?
- References: <119.1ed63774.2b77b6ed@aol.com>
>- I get wrong results when compiling
>
> double relval[n] ;
>
> cadd: relval[gjj+1]+=3Drelval[gjj++] ;
>
>with the Intel/Linux compiler, using
>
> icc -c -march=3Dpentium4 -O2 adder2.c
>This is different. The gcc compiler produces correct results in my
>(much larger) application, and the Intel compiler does not. Am I
>doing something wrong, or is this a compiler bug?
If you post-increment gjj in one part of an expression and then use it
in another, then the results are "implementation-defined", which is to
say that the compiler is free to choose where to apply the side effect
of the post-increment, and in your example you are relying on a
particular behavior.
Change the code to:
double relval[n] ;
cadd: relval[gjj+1]+=relval[gjj];
gjj++;
which makes it is explicit where the post-increment of gjj takes place.
--
Peter Barada
peter@baradas.org