campreilly / UnderSeaModelingLibrary

The Under Sea Modeling Library (USML) is a collection of C++ software development modules for sonar modeling and simulation.
Other
45 stars 22 forks source link

GNU C++ Release Build Requires USML_PEDANTIC be Set #38

Closed islanderjtn closed 9 years ago

islanderjtn commented 11 years ago

It has been found that under certain situations using the GNU C++ compiler and the build type set to Release, USML calls to Profile_3 class of sound_speed return NaN's, ie Not a Number. If the USML_PEDANTIC setting is also selected along with the build set to Release this does not occur.

This issue was found in SST integration CppUnit test for WOAProfile. The USML_PEDANTIC setting adds the following definitions: -std=c++98 -pedantic -Wall -Werror -Wno-long-long -Wno-sign-compare

While it is not clear what exactly is causing this issue at this time it is believed that the reduction of optimization features from the USML_PEDANTIC setting allows for the fix. Possible candidate is the uBlas library.

WorkAround - Always set the USML_PEDANTIC in cmake for GNU C++ Release Builds.

campreilly commented 10 years ago

We don't want to use pedantic at customer sites, because it is just a way checking our own work for standards compliance. If their compilers are slightly different, we still want to let them compile.

Need to re-visit this.

campreilly commented 9 years ago

Revisit and re-test.

islanderjtn commented 9 years ago

After some more in depth analysis, see issue #93, this issue is actually related to the -ffast-math tag. The PEDANTIC setting set the -std=c++98 compiler flag, this flag in turn prevented the -ffinite-math-only flag from being set via the -ffast-math flag, as it is with the default -std=gnu++98 dialect. Added the tag -fno-finite-math-only tag after the -ffast-math for Release builds in the usmlBuildSetup.cmake file. This turns off the flag -ffinite-math-only flag provided by -ffast-math, NaNs produce expected results.