Open
Description
Title: Can't use CTAD for type-scope object alias.
Minimal reproducer (https://cpp2.godbolt.org/z/63occKT7x):
#include <array>
arr0: std::array == :std::array = (0);; // OK.
t: @struct type = {
arr1: std::array == :std::array = (0);; // error.
}
main: () = { }
Commands:
cppfront main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result:
A definitely not-incomplete object type
to be defined in the class' body.
public: static constexpr std::array arr1 = std::array{0};
Actual result and error:
//=== Cpp2 type definitions and function declarations ===========================
public: static const std::array arr1; // error.
//=== Cpp2 function definitions =================================================
inline constexpr std::array t::arr1 = std::array{0};
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
class t;
//=== Cpp2 type definitions and function declarations ===========================
#include <array>
std::array inline constexpr arr0 = std::array{0};// OK.
class t {
public: static const std::array arr1; // error.
};
auto main() -> int;
//=== Cpp2 function definitions =================================================
inline constexpr std::array t::arr1 = std::array{0};
auto main() -> int{}
main.cpp2:4:35: error: declaration of variable 'arr1' with deduced type 'const std::array' requires an initializer
4 | public: static const std::array arr1; // error.
| ^
1 error generated.
See also:
- Commit b589f5d.
- [BUG] Function overloading with an @enum type produces unexpected results #687.
- [SUGGESTION] Improve
in
parameter passing (restore old behavior, exclude problem cases only) #666 for more of "definitely not-incomplete object type".