-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+ runtime check of rounding mode support #8
base: develop
Are you sure you want to change the base?
Conversation
Ok, I'm confused. I tried your program using gcc 5.1 on Mac OS X, and it did nothing with both What is the behavior that you expect from this program (and what is the behavior that you observe)? |
I expect (and I observe with gcc 5.1.0, clang 3.6.0 on ArchLinux) that after applying my patch for Boost.Interval program built without -frounding-math aborted with error
Possibly, absence of crash on MAC OS X can be explained by another set of predefined command line options for gcc. Could you try to pass |
👍 |
Couldn't this be a compile-time check? |
I'm afraid no. Firstly constexpr evaluation doesn't support rounding mode. Secondly correctly built program will crash if run it on Valgrind. |
Using the docker ubuntu bionic image (clang 6, gcc 7.3, valgrind 3.13, found in boostorg/boost#184) I am able to reproduce this issue on the "pi" test in release mode: gcc with -fno-rounding-math:
gcc with -frounding-math:
clang 6:
Unable to use clang with -fno-rounding-math:
As it stands you can't use clang at all, and you can only use gcc in one mode. I'm thinking it's the library or the test that's at fault here and not the compiler(s)... |
{}; | ||
|
||
template<> | ||
struct rounded_math<double> | ||
: save_state<rounded_arith_opp<double> > | ||
, private detail::runtime_checker<double> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this increase the runtime performance significantly if these are used in hot code paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't because it is invoking only once (static helper _
, line 59). There is still some performance penalty due to the check that singleton of the type helper
is initialized, but I believe that it's insignificant in comparison to the cost of switch of rounding mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase on develop.
For example, following program <code> #include <boost/numeric/interval.hpp> int main() { boost::numeric::interval<double>::traits_type::rounding _; } </code> will work fine if is built with gcc using '-frounding-math', but will fail otherwise. Running on Valgrind is another practical case when this program will crash (even if it was correctly built).
For example, following program
will work fine if is built with gcc using '-frounding-math', but will fail otherwise.
Running on Valgrind is another practical case when this program will crash (even if it was correctly built).
I am not sure about using
assert
for check, may be exception or some other mechanism should be used.