从一个新的位置访问一个静态constexpr成员是一个常量表达式吗?
澄清一下,以下程序格式是否正确?
#include <new>
char foo[32];
struct bar {
static constexpr int foobar = 42;
};
int main()
{
auto p = new (foo) bar();
static_assert(p->foobar == 42);
}
gcc和msvc接受,但clang因错误而拒绝
read of non-constexpr variable 'p' is not allowed in a constant expression,谁是对的?