-
Notifications
You must be signed in to change notification settings - Fork 151
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
Undefined return value on GCC/MSVC with -O2 using "auto" #84
Comments
Thanks @Faaux. I have a simplified version with no extra additional type using the Seems that our tests do not include optimization: |
Dear @Faaux You can prevent such behavior by not copy-constructing expression template objects, as you already have presented in your example. We will fix this bug with the next releases by restructing and revisiting expression templates with tensors, matrices and vectors. Either we will use Boost.Yap as already presented in our GSoC19 project or fully get rid of expression templates. The GSoC20 project will provide the latest changes for Boost.uBlas. Thanks. |
Hey @bassoy I was wondering if there is a quick way to determine when this is happening? I am working with a pre-existing code-base and there are possibly quite a lot of situations where this could occur. I have found (by now) three situations where this is happening. This is new to us since we are currently in the process of upgrading Boost to 1.73. This could be breaking for us! Maybe a patch that deletes the copy-constructor, just to determine where we are using it? Best, |
As in the inital bug report defining Thanks again! Edit: For our use-case it might be possible to overload the according operators. Something like: https://godbolt.org/z/BHLwV9 Am I missing something? |
As you have already found out, the problem occurs when you copy construct an expression template.
We are working on a completely new stable solution using Boost.Yap which will be thoroughly tested and more powerful.
|
Hey @bassoy, any update or timeline on this? |
@Faaux thanks for asking. Yes, we have found the root cause and propose two possible solutions, see #125. A quick solution is to directly use tensor, matrix or vector objects on the lhs of the expression. This will not slow down your program and you program will produce the correct results. Hope this helps. |
Thanks for letting me know and glad you found a fix. Sadly that still is not an option to change a larger codebase and find all instances to change the auto. I have a workaround in place, thanks for your work :) |
Dear everyone,
I hope you are doing well. I stumbled across an oddity using ublas::vector which I am not able to explain. Any information as to why this happens and how it can be prevented would be very appreciated. I have reproduced the issue in Compiler-Explorer:
https://godbolt.org/z/pknvaB
Description [Boost 1.73]:
Doing simple vector arithmetic on a fixed sized vec3, I get different (wrong) results using the "auto" keyword once any optimizations (anything other than -O0) are in place on GCC and MSVC. Clang does not have this problem. I attached the code used in Compiler-Explorer to this E-Mail.
Defining BOOST_UBLAS_SIMPLE_ET_DEBUG seems to also resolve the issue?
Is this the right spot to ask this question or should I post this to the Mailing List aswell?
Best,
Faaux
The text was updated successfully, but these errors were encountered: