cppfront
cppfront copied to clipboard
[BUG] Can't declare constexpr variable of pointer type
trafficstars
Title: Can't declare constexpr variable of pointer type.
Minimal reproducer (https://cpp2.godbolt.org/z/voMavfKhh):
main: () = {
_: * const char == "abc";
}
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result: constexpr char const* _ = "abc"; or std::type_identity_t<char const*> constexpr _ = "abc";.
Actual result and error: char const* constexpr _ = "abc";.
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
//=== Cpp2 type definitions and function declarations ===========================
auto main() -> int;
//=== Cpp2 function definitions =================================================
auto main() -> int{
char const* constexpr _ = "abc";
}
Output:
main.cpp2:2:15: error: expected unqualified-id
2 | char const* constexpr _ = "abc";
| ^
1 error generated.
See also:
- #525.
- #724.