-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Clang cannot compute at compile time typeid
of a variable of concrete class type with vtable
#63117
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
Comments
@llvm/issue-subscribers-c-20 |
@llvm/issue-subscribers-clang-frontend |
Doesn't require C++20, you can see the same "not constant expression" behavior with an array index: https://godbolt.org/z/P54G99a53 |
Oops, constexpr typeid, however, is a C++20 feature, so this does require C++20 after all. :-) |
@llvm/issue-subscribers-c-20 |
http://eel.is/c++draft/expr.const#5.26 disallows use of It's worth noting that GCC does not seem to properly note when the type is constexpr-unknown, though MSVC does: https://godbolt.org/z/x8a4c5xdq |
Related #63139 |
…nstant expressions P2280R4 allows the use of references in pointers of unknown origins in a constant expression context but only in specific cases that could be constant expressions. We track whether a variable is a constexpr unknown in a constant expression by setting a flag in either APValue or LValue and using this flag to prevent using unknown values in places where it is not allowed. In `evaluateVarDeclInit` we may need to create a new `APValue` to track the unknown referene or pointer and we track that `APValue` in the `CallStackFrame`. Fixes: llvm#63139 llvm#63117
…nstant expressions (#95474) P2280R4 allows the use of references in pointers of unknown origins in a constant expression context but only in specific cases that could be constant expressions. We track whether a variable is a constexpr unknown in a constant expression by setting a flag in either APValue or LValue and using this flag to prevent using unknown values in places where it is not allowed. Fixes: #63139 #63117
…ences in constant expressions (#95474) P2280R4 allows the use of references in pointers of unknown origins in a constant expression context but only in specific cases that could be constant expressions. We track whether a variable is a constexpr unknown in a constant expression by setting a flag in either APValue or LValue and using this flag to prevent using unknown values in places where it is not allowed. Fixes: llvm/llvm-project#63139 llvm/llvm-project#63117
Fixed by #95474 |
Uh oh!
There was an error while loading. Please reload this page.
On this code:
Clang produces the following error:
Even though
typeid
can be computed at compile time (sinced
is not a reference and has a concrete object type).GCC and MSVC compile this code with no errors, see Godbolt.
The text was updated successfully, but these errors were encountered: