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
Test of channel_invert<int> failing with clang 5.x and variant=release #89
Comments
Can you reduce the code sample to just the "-1" result? We could take it to the boost ml then. |
I really hoped that is quite a minimal sample, but if you want just the
|
Sorry to be so annoying. I was thinking of just a one or two liner without any function call. Sometimes the problem goes away... |
That is exactly the reason why I stick to the function template(s). This should make it more clear:
The sample output of this program compiled with clang 5.0.0 with optimization:
|
I posted this sample to clang mailing list [cfe-users] Boost.GIL test failing with clang 5.x while pass with 15 gcc/clang versions. |
Good idea! I don't have clang right now. Hopefully someone will take a look. |
I also posted it to Boost developer's list https://lists.boost.org/Archives/boost/2018/05/242170.php |
Yeah, saw that. Now all we need is just on answer. ;-) Probably a compiler bug, right? |
We've got one response to the cfe-users thread: http://lists.llvm.org/pipermail/cfe-users/2018-May/001336.html. My suspicions about the bug in GIL seem to be confirmed:
I think I mentioned that earlier somewhere, via e-mail or on GIL ml, we may need some integral type selectors and explicit conversions to larger types. For example, something along these concepts: Finally, we should enable the sanitizers for clang and/or GCC builds on CI services. |
On 05/21/18 13:52, Mateusz Loskot wrote:
We've got one response to the cfe-users thread:
http://lists.llvm.org/pipermail/cfe-users/2018-May/001336.html.
My suspicions about the bug in GIL seem to be confirmed:
BTW This is a perfect opportunity to try out
UndefinedBehaviorSanitizer!
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
|clang++ -fsanitize=signed-integer-overflow overflow.cpp ./a.out
-2147483648 overflow.cpp:24:52: runtime error: signed integer
overflow: 2147483647 - -2147483648 cannot be represented in type
'int'|
Excellent find !
||
I think I mentioned that earlier somewhere, via e-mail or on GIL ml,
we may need some integral type selectors and explicit conversions to
larger types.
For example, something along these concepts:
https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/util/promote_integral.hpp
https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/util/select_most_precise.hpp
I fully agree. These seem simple enough (and self-contained) that it
might make sense to simply clone them into the GIL repo.
|
@stefanseefeld Good. I will work on integrating the type selectors into GIL. |
This should help to avoid UB due to possible signed integer overflows, for minimum/maximum of input channel domain. Fixes boostorg#89
This should help to avoid UB due to possible signed integer overflows, for minimum/maximum of input channel domain. Fixes boostorg#89
This should help to avoid UB due to possible signed integer overflows, for minimum/maximum of input channel domain. Fixes #89
I'm happy to confirm the UB due to signed integer overflow has been now fixed by #94 and the clang 5.0 build tests pass https://circleci.com/workflow-run/f79210be-b033-402c-aefb-6461d897c88a |
@mloskot Congrats! |
This should help to avoid UB due to possible signed integer overflows, for minimum/maximum of input channel domain. Fixes #89
This issue reproduces failure of CircleCI build https://circleci.com/gh/boostorg/gil/829 with clang 5 due to failure in
line 22
of this test targettingchannel_invert<int>
:gil/test/channel/algorithm_channel_invert.cpp
Lines 19 to 24 in e9b2a68
Minimal Working Example (in C++)
Actual behavior
int
Expected behavior
Question
For
x = -2147483648
, this value inverting expressiondoes seem to promote
int
tounsigned int
at least due to the partial value of2147483647 - (-2147483648) = 4294967295
Let's consider that:
channel_invert
tests are not failing for Travis CI or AppVeyor.Are we experiencing a compiler bug or nasty UB? Your bets @chhenning @stefanseefeld?
References
This may be directly related to the issue #51
The text was updated successfully, but these errors were encountered: