Skip to content
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

Aggressive optimization breaks the code and removes checks #23196

Closed
mkurdej opened this issue Mar 6, 2015 · 1 comment
Closed

Aggressive optimization breaks the code and removes checks #23196

mkurdej opened this issue Mar 6, 2015 · 1 comment
Labels
bugzilla Issues migrated from bugzilla clang:codegen invalid Resolved as invalid, i.e. not a bug

Comments

@mkurdej
Copy link
Member

mkurdej commented Mar 6, 2015

Bugzilla Link 22822
Resolution INVALID
Resolved on Mar 06, 2015 12:13
Version 3.6
OS All
Attachments Minimal example of the code causing the problem
CC @dwblaikie,@hfinkel

Extended Description

The attached code is miscompiled at optimization levels -Os and above and the checks in checked_add function are apparently ignored.
Reproduced on FreeBSD and Windows with clang 3.5.0 (release=r217039) and 3.6.0(tags/RELEASE_360/final).

@dwblaikie
Copy link
Collaborator

Looks like undefined behavior to me.

signed integer overflow (as happens at the beginning of the call to checked_add when passed max_int) is undefined. Since your program unconditionally executes that addition, the behavior of the entire program is undefined - nothing it does, even before the point of the addition, is guaranteed by the C++ standard.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:codegen invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

2 participants