Describe the bug
I have a Cpp1 class with some integral const static members initialized inside class. This allows me to use them to declare other members, notable std::array. Tried to port the class to Cpp2, but the static members are initialized outside the class, so I cannot use them to declare a std::array.
Command lines including which C++ compiler you are using
For Cpp2: cppfront.exe main.cpp2 -import-std
Visual Studio Community 2022 (64-bit) Version 17.10.5
Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33813 for x86
Project -> Properties -> Configuration Properties -> C/C++ -> Command Line:
Expected result
To compile to my original code or to compile to static constexpr size_t kWidth{ 4 }; // omitting the rest for brevity
Actual result/error
Error: Code C2975, '_Size': invalid template argument for 'std::array', expected compile-time constant expression
Generated Cpp1 code (normally i don't use -clean, but I'm pasting here the clean version)
Describe the bug I have a Cpp1 class with some integral
const static
members initialized inside class. This allows me to use them to declare other members, notablestd::array
. Tried to port the class to Cpp2, but the static members are initialized outside the class, so I cannot use them to declare astd::array
.To Reproduce Steps to reproduce the behavior:
Sample code
My original Cpp1 code
Cpp2 code:
For Cpp2:
cppfront.exe main.cpp2 -import-std
Visual Studio Community 2022 (64-bit) Version 17.10.5
Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33813 for x86
Project -> Properties -> Configuration Properties -> C/C++ -> Command Line:
static constexpr size_t kWidth{ 4 }; // omitting the rest for brevity
Actual result/error
Error: Code C2975, '_Size': invalid template argument for 'std::array', expected compile-time constant expression
Generated Cpp1 code (normally i don't use -clean, but I'm pasting here the clean version)
Additional context cppreference.com static members