bin/43299: march=pentium4 miscompiles msun/src/e_pow.c

David Schultz das at FreeBSD.ORG
Wed May 14 02:42:32 PDT 2003

On Tue, May 13, 2003, Mikhail Teterin wrote:
> It seems like the problem is inside the SET_HIGH_WORD(ax, ix) macro
> on line e_pow.c:214, which expands into
> into
> 	do {
> 		ieee_double_shape_type sh_u;
> 		sh_u.value = (ax);
> = (ix);
> 		(ax) = sh_u.value;
> 	} while (0);
> for whatever reason, if compiled for pentium4 with -O1, the line
> 	sh_u.value = (ax)
> is SKIPPED -- according to the debugger. ax ends up filled with junk,
> which screws everything up afterwards... I'm attaching the simple test
> file (the skipped line is 34 in it). If compiled for p3 or for p4 with
> -O0, the result is 0.5. When compiled for p4 with -O1, the result
> is junk. The junk is persistent -- I'm getting ``5.29463e-315'' on
> both FreeBSD (gcc version 3.2.2 20030205) and Linux (gcc version 3.2
> 20020903).

The C standard does not make any provisions for type punning,
except for chars.  However, SET_HIGH_WORD is doing it in the
generally accepted way, which gcc claims to support.  This looks
like a bug in gcc, and you seem to have determined that it is not
FreeBSD specific.  It should probably be reported to the gcc folks
if it is still a problem in a recent gcc 3.3 snapshot.  (It's
great that you found a short test case; they appreciate that.)

BTW, thanks for taking the time to look into this!  I don't have a
P4 to test on or enough free cycles at the moment.

More information about the freebsd-bugs mailing list