[M3devel] A warning on dtoa.h
Tony Hosking
hosking at cs.purdue.edu
Wed Aug 22 19:34:37 CEST 2007
Yes, I've been burned by this in the past too. For that reason, all
my cm3.cfg files use -O in compile_c instead of -O3. I note that
there is an updated dtoa, which perhaps we should be using instead,
though I don't know if gcc optimizations still cause issues with it.
I seem to recall it was something to do with aliasing, which gcc
generates appropriate warnings for.
I note that the newer dtoa requires some locking for preemptively-
scheduled threads (as our later PTHREAD systems do), so perhaps some
work is in order here. Here is the newer dtoa:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dtoa.c
Type: application/octet-stream
Size: 67983 bytes
Desc: not available
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20070822/761c76a4/attachment-0005.obj>
-------------- next part --------------
On Aug 22, 2007, at 12:28 PM, Rodney M. Bates wrote:
> I have located a case where dtoa.h (which is in libm3core) gives a
> wrong result when compiled by gcc 3.4.3 -O2 but works correctly
> with -O0. When compiled by gcc 4.1.1, this case works correctly
> with either optimization level.
>
> Whether this is a bug in gcc 3.4.3 -O2, or whether dtoa.h has some
> "undefined" code remains to be seen.
>
> In either case, beware. It caused pm3 to miscompile the REAL constant
> 2.0, used in Table.mg, which made an instantiation of Table get a
> false
> runtime range error. It took days to track down. I had another
> instance of a bad real constant being compiled from a long time ago,
> that I never diagnosed.
>
> cm3 uses a virtually identical dtoa.h, and nothing in the call chain
> leading up to the instance where I found the problem is materially
> changed from pm3 to cm3, so probably cm3 is affected in the same
> way.
> --
> -------------------------------------------------------------
> Rodney M. Bates, retired assistant professor
> Dept. of Computer Science, Wichita State University
> Wichita, KS 67260-0083
> 316-978-3922
> rodney.bates at wichita.edu
More information about the M3devel
mailing list