-
Notifications
You must be signed in to change notification settings - Fork 125
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
UBSan complains when doing left shift for some inputs #301
Comments
I'm not inclined to implement this. It's a run time, not a compile time cost that is incurred by everyone for a very, very small number of potential situations. That's like running ubsan every time, instead of only during testing. What do you want to do in undefined behaviour cases? Throw an error? Perhaps it could be a configurable compile time option, but someone else will need to implement it. Perhaps some of the simpler cases are easy enough like shifting by a negative number, overflow checking of addition, multiplication and negation seem harder |
I see. That's understandable.
Well, yeah.. That was an idea I had in mind.
So basically you are not against patches that may address this right?
I personally interested in improving this in context of OpenOCD tasks. For example it seems reasonable that operations like |
Yes, completely open to patches that are not detrimental (e.g. performance) to most users, or if so, then it is a configuration-time setting that can be turned off as required. |
Build:
Run jimsh:
Another issue is that interpreter allows for inputs such as these:
Technically, some of these cases can be considered as incorrect user input, since jimtcl operates on signed integers internally. Still, interpreter allows for such inputs...
{ 1 << 63 }
one could detect that both operands are non-negative and perform operation on unsigned type, converting the result back to signed (leading to implementation-defined behavior till C23)To be fair all this may be an overkill. However, fixing this may simplify sanitize-based checks for applications that embed jimtcl.
The text was updated successfully, but these errors were encountered: