-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
clang: constexpr does not honor -fwrapv, leading to compilation error #59195
Comments
We seem to be consistent with gcc in most cases although the I believe command line options should not modify whether an expression is considered well-formed in a constant expression or not b/c this has wider impacts on portability due to use in templates and other scenarios that required constant expression such as support for variable length arrays as an extension. Although I will leave it open to allow for more feedback if others want to weigh in. |
Yes, gcc has a similar but not identical problem/view. Reported as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107861 |
100% agreed |
@llvm/issue-subscribers-clang-frontend |
I get your point, but please note that we already have such command line options. godbolt link: https://godbolt.org/z/5EvdhWha8
|
Not the same. The standard says it's unspecified whether char is signed or unsigned. It doesn't say it's unspecified whether |
So you're saying that |
Unspecified behavior still results in a well-formed program:
Even though unspecified behavior is well-formed it is not portable and developers need to be aware of that and design accordingly. Undefined behavior is never well-formed. It is a runtime behavior and even though we have command line options to define the behavior at runtime undefined behavior is not allowed in a constant expression:
and includes the following bullet:
|
Godbolt link: https://godbolt.org/z/8KhvbcWr6
Reproducible with clang-trunk
The text was updated successfully, but these errors were encountered: