The following program is failing when compiling with Clang with error: constexpr variable 'struct2Var' must be initialized by a constant expression {var, 2100433} .
If I remove __attribute__((weak))
from "var" declaration, it is passing without any issues.
Can somebody please explain the theory/reason behind this error.
struct myStruct
{
public:
constexpr operator const wchar_t*() const
{
return &m_cch;
}
const wchar_t m_cch;
};
extern __attribute__((weak)) const constexpr myStruct var {'a'};
struct myStruct2
{
const wchar_t* stzKey = nullptr;
int intvar = 0;
};
static constexpr const myStruct2 struct2Var[1]
{
{var, 2100433}
};