P
Phil Carmody
Tim Prince said:SSE2 platforms have been the norm for 8 years
Yes, yes, all the world's a VAX, you're quite right.
Phil
Tim Prince said:SSE2 platforms have been the norm for 8 years
I don't find "dodgy" results obtained by options for targets of moreBen said:The same applies to 4.3.3, of course, but I did not want to post a set
of unsurprising results!
Tim Prince said:Ben Bacarisse wrote:
I don't find "dodgy" results obtained by options for targets of more
than 8 years ago so surprising either.
icc/ia32 got around to making
P4 a default target a year ago.
gcc has such a "surprising" default only for i386.
I'm equally
inclined to complain to my employer's IT for locking my laptop down to
32-bit Windows last week as to complain to c.l.c about gcc defaults.
If you want to discuss why a certain compiler has obsolete defaults,
if it is a currently maintained compiler, there should be a more
suitable forum. (e-mail address removed) for example.
Joe Wright said:Exactly my point, thanks. Optimization shouldn't affect this and so I
think it a gcc bug.
Richard Heathfield said:Ben Bacarisse said:
5.2.4.2.2 p8:
Except for assignment and cast (which remove all extra range and
precision), the values 8 of operations with floating operands
and values subject to the usual arithmetic conversions and of
floating constants are evaluated to a format whose range and
precision may be greater than required by the type. The use of
evaluation formats is characterized by the
implementation-defined value of FLT_EVAL_METHOD: [followed by
the text already quoted by pete]
The first line has a change bar against it in my copy of
n1256.pdf. This means (I think) that some part of that text was
changed after
publication. I don't have any other copy to hand so I don't know
exactly what has changed. It seems, anyway, that casts and
assignment are exempted and must remove extra precision.
If we compare the above to the original paragraph from ISO/IEC
9899:1999 (note that, in the original, it is actually para7, not
para8), we find that the revision has inserted the words "Except
for assignment and cast (which remove all extra range and
precision)". Otherwise, it is as quoted above.
pete said:What is n1256.pdf supposed to be?
Is it a revision of the last standard
or a proposal for the next?
Keith said:N1256 is a revision of C99, consisting of the text of the C99 standard
with the three Technical Corrigenda merged into it (and I think the
editor snuck in some minor editorial changes while he was at it).
It's a draft, not an "official" document.
James Kuyper said:It should be emphasized that all of the source documents for n1256 are
official. The Technical Corrigenda were approved in the form of
changes to be made to the C99 standard, and n1256 is intended only to
show what the standard would look like with those changes made to
it. It has the string "Septermber 7, 2007" at the top of every page of
the document. To the best of my knowledge, in the nearly two years
since that date, the only defect that has been reported against that
document in the type which appears in that date.
It may be unofficial, but by reason of combining all the official
documents together the way they were intended to be, I find it more
useful than any of the official documents.
gcc 4.3.3-O0 equal, equal
-O1 not equal, equal
-O1 -ffloat-store equal, equalicc 10.0-O0 equal, equal
-O1 not equal, no equal[snipped]
gcc 4.5 win32
-O -march=pentium-m -mfpmath-sse equal,equal
icl 11.1 win32
-prec-div equal,equal
SSE2 platforms have been the norm for 8 years, and most compilers have
caught up.
Keith said:....
Except that by "in the type", I presume you meant "is the typo".
You're over-simplifying this. All recent versions of Visual StudioMark said:gcc 4.5 win32Ben said:<snip>
Puzzling.
#include <stdio.h>
#include <stdlib.h>
int main(void) {
double a, b;
if ((a=(double)atoi("1")/atoi("3")) ==
(b=(double)atoi("1")/atoi("3")))
puts("equal");
else
puts("not equal");
if (a == b)
puts("equal");
else
puts("not equal");
return 0;
}
Prints
not equal
equal
gcc 3.1
gcc 4.3.3
-O0 equal, equal
-O1 not equal, equal
-O1 -ffloat-store equal, equal
icc 10.0
-O0 equal, equal
-O1 not equal, no equal
[snipped]
-O -march=pentium-m -mfpmath-sse equal,equal
icl 11.1 win32
-prec-div equal,equal
SSE2 platforms have been the norm for 8 years, and most compilers have
caught up.
This may have more to do with Windows than with SSE2:
I believe that Windows sets the x87 FPU precision to
53 bits by default, while many other x86 operating
systems (Linux, Solaris, OS X; not FreeBSD) leave
the x87 precision setting at its default of 64 bits.
Mark said:Ben Bacarisse wrote:
<snip>
Puzzling.
#include <stdio.h>
#include <stdlib.h>
int main(void) {
double a, b;
if ((a=(double)atoi("1")/atoi("3")) ==
(b=(double)atoi("1")/atoi("3")))
puts("equal");
else
puts("not equal");
if (a == b)
puts("equal");
else
puts("not equal");
return 0;
}
Prints
not equal
equal
gcc 3.1
gcc 4.3.3
-O0 equal, equal
-O1 not equal, equal
-O1 -ffloat-store equal, equal
icc 10.0
-O0 equal, equal
-O1 not equal, no equal
[snipped]
gcc 4.5 win32
-O -march=pentium-m -mfpmath-sse equal,equal
icl 11.1 win32
-prec-div equal,equal
SSE2 platforms have been the norm for 8 years, and most compilers have
caught up.This may have more to do with Windows than with SSE2:
I believe that Windows sets the x87 FPU precision to
53 bits by default, while many other x86 operating
systems (Linux, Solaris, OS X; not FreeBSD) leave
the x87 precision setting at its default of 64 bits.
You're over-simplifying this. All recent versions of Visual Studio
run-time for 32-bit Windows set 53-bit precision mode during
initialization, but it's possible to run gcc (as I did), where that
doesn't happen.
Windows 64-bit sets 53-bit precision mode before handing over control to
.exe, even if that .exe is built by gcc. However, compilers for X64 use
sse2 by default, so you won't see the "surprising" extra precision.
53-bit precision mode will avoid the so-called "surprising" results for
this example, but not for analogous examples using float data types.
[...]
James Kuyper said:It should be emphasized that all of the source documents for n1256 are
official. The Technical Corrigenda were approved in the form of changes
to be made to the C99 standard, and n1256 is intended only to show what
the standard would look like with those changes made to it. It has the
string "Septermber 7, 2007" at the top of every page of the document. To
the best of my knowledge, in the nearly two years since that date, the
only defect that has been reported against that document in the type
which appears in that date.
Mark Dickinson said:Can someone explain why this behaviour doesn't contravene
C99 5.1.2.3, paragraph 12? "... In particular, casts and
assignments are required to perform their specified
conversion"?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.