This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: What is wrong with Bugzilla? [Was: Re: GCC and Floating-Point]


--- Daniel Berlin wrote:
> 
> Let's take a duplicate of 323, 21809
> 
> 
> Compiling the code there with icc gives us:
> 
> dberlin@linux:~> icc icca.c
> icca.c(7): warning #1572: floating-point equality
> and inequality
> comparisons are unreliable
>     assert(a == x);
>     ^
> 
> ./dberlin@linux:~> ./a.out
> a.out: icca.c:7: main: Assertion `a == x' failed.
> Aborted
> 
> In order to get icc to not generate an executable
> that will abort, you
> have to pass special flags (the same way we have
> -ffloat-store, except I
> believe their -mp flag will just disable any
> optimization that could get
> in the way of this working).
> 
> One of these flag options is to tell it to use
> processor specific
> instructions, which auto turns on the equivalent of
> -mfpmath=sse.
> 

Here is another case for you try out:

test.c:
#include <assert.h>
#include <stdio.h>

volatile float x = 3;

int main()
{
	float a = 1 / x;
	x = a;
	assert(a == x);
	printf("a has value of %g \n",a);
	printf("x has value of %g  \n",x);
	assert((int)a == 0);
	assert((int)x == 0);
	return 0;
}


Compile this gcc {-O0,-O1,-O2,-O3,-Os}

You will notice it will always works  (despite not
using  -ffloat-store) and not cause an assertion
failure at all.

























		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]