从一个新的位置访问一个静态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,谁是对的?

以上是从一个新的位置访问一个静态constexpr成员是一个常量表达式吗?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>