2024-11-24 11:16 AEDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000348mercuryBugpublic2015-07-08 13:15
Reporterjuliensf 
Assigned Tojuliensf 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000348: Failure of tests/general/string_format_special_floats with MSVC
DescriptionWhen using MSVC as a C compiler, the test case tests/general/string_format_special_float fails as the MS libc doesn't appear to
implement the C99 behaviour for printing nan, inf etc.

With VS2012 we get:

Plus Infinity:
                  %e: failure '1.#INF00
                  %f: failure '1.#INF00
                  %g: failure '1.#INF'
                  %E: failure '1.#INF00
                  %F: failure ''
                  %G: failure '1.#INF'
Minus Infinity:
                  %e: failure '-1.#INF0
                  %f: failure '-1.#INF0
                  %g: failure '-1.#INF'
                  %E: failure '-1.#INF0
                  %F: failure ''
                  %G: failure '-1.#INF'
Not a number:
                  %e: failure '-1.#IND0
                  %f: failure '-1.#IND0
                  %g: failure '-1.#IND'
                  %E: failure '-1.#IND0
                  %F: failure ''
                  %G: failure '-1.#IND'

We should probably check for special float values before calling sprintf
and just handle them directly using Mercury. (This would also avoid some
inconsistencies in the output of these tests due to do differences in C
libraries.)
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0000747

juliensf (administrator)

The same problem also affects tests/hard_coded/write_float_special.

~0000748

wangp (developer)

For what it's worth, NaNs were printed on AIX as "NaNQ", where 'Q' stands for quiet.

~0000750

juliensf (administrator)

C99 says they should be printed as: nan, -nan, nan(...) or -nan(...) where "..." is an implementation-defined sequence of letters, digits or underscores. (Or in uppercase if %F is used.)

~0000755

juliensf (administrator)

I intend to address this one by checking for, and handling, inf and nan (although nan should really cause an exception to be thrown) in Mercury rather than relying on sprintf. Even with C99 there are too many annoying little differences in how inf and nan are handled. Dealing with Java and C# just complicates things further.

~0000838

juliensf (administrator)

Fixed in commit 4e15777.
+Notes

-Issue History
Date Modified Username Field Change
2014-07-18 15:07 juliensf New Issue
2014-07-18 15:46 juliensf Note Added: 0000747
2014-07-18 16:23 wangp Note Added: 0000748
2014-07-18 17:01 juliensf Note Added: 0000750
2014-08-06 10:37 juliensf Note Added: 0000755
2014-08-06 10:37 juliensf Assigned To => juliensf
2014-08-06 10:37 juliensf Status new => assigned
2015-07-08 13:15 juliensf Note Added: 0000838
2015-07-08 13:15 juliensf Status assigned => resolved
2015-07-08 13:15 juliensf Resolution open => fixed
+Issue History