C++ compilers on Linux supporting 64bit architecture?

Chris Jones jonesc at hep.phy.cam.ac.uk
Sun Sep 2 10:13:46 UTC 2007


> >  float x = pow( 10, -6 );
> >
> > on linux this gives you 1e-6. On windows you get 0 !!
>
> You do?  I don't.  Not with VC++-2005 and not with gcc in Cygwin.  I get
> 1e-6 on every platform I've tried so far.  How did you do that
> experiment?

I didn't do it myself, I must confess. It was reported be a work colleague 
recently who was trying to iron out differences in an application between 
linux (gcc3.4.6 on SLC4) and windows (vc++ 7.1, so the '2003' one). 

I guess the problem must have been fixed between VC 2003 and 2005 ?

>
> > std::sort( .... ); The STL standard states that for elements that are
> > "equal" (whatever that means for the predicate) the final order is not
> > defined. Anything which is not defined in the standard you can read as
> > possibly platform dependant. IN this case the fix is easily, as
> > std::stable_sort(...) is for exactly this case, as in preserve the
> > original order of 'equal' elements.
>
> That's true anywhere.  "Undefined" means t's not even guaranteed that
> you get the same output for two successive runs of the same program on
> the same machine.

Agreed. Although in this case we hadn't noticed any repeatability problems, 
but that must likely just luck. In general don't rely on any undefined 
behavior. My point was its easy to not realize you are using some undefined 
behavior, until you compare two different compilers etc.

Chris





More information about the fedora-list mailing list