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
Empty struct is wrongly treated as a compile-time constant in C++ #53479
Comments
This is the standard C++ behavior. A function parameter, being provided by the caller, is never treated as a compile-time constant. It's never okay to write
because Making the function
|
@llvm/issue-subscribers-c-1 |
@llvm/issue-subscribers-clang-frontend |
Actually, I take it back. The Clang bug here is that
Changing |
Given following code( https://www.godbolt.org/z/v9r5691bG ) , it gives error "non-type template argument is not a constant expression" of "takeInt(n)", complaining "n" has unknown value even though "takeInt" is constexpr returning value of "0".
However, similar function with parameter type of struct B passes compilation:
Why does parameter "b" as struct passes while "n" as int fails? These are parameter to function "takeB" and "takeInt" which is not template argument of "A". The template argument of "A" is the constexpr function expression "takeB(b)" and "takeInt(n)" which evaluates to be constexpr value "0".
The text was updated successfully, but these errors were encountered: