On Sat, 2007-09-01 at 14:59 +0100, Chris Jones wrote: > Even once you have worked through the slight oddities that mean C++ on windows > isn't quite the same as C++ on linux, you can find cases where at run time > you don't get the same results. If this is important to you it can be a right > pain to trace problems. A couple examples found recently in a project I work > on that supports both windows and linux, > > 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? > > 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. > > These are just two examples, I'm sure there are many other ways in which you > could find linux and windows don't give identical results. If you care about > this, you might have a lot of debugging on your ands. > > On the plus side, testing your code on two quite different platforms is quite > enlightening and useful in a testing sense. Both linux and windows can have > oddities and things which diverge from the standard, and this is a great way > to find them.... Absolutely. Different hardware with the same software can also make a difference. Note that divergence from the standard is a compiler bug (and should be reported as such to the vendor). Relying on behavior that is not specified by the standard is dangerous, at best, especially for code that is to be run cross-platform. > > Chris > > > -- Matthew Saltzman Clemson University Math Sciences mjs AT clemson DOT edu http://www.math.clemson.edu/~mjs -- fedora-list mailing list fedora-list@xxxxxxxxxx To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list