static constexpr const char* a[] = {"foo", "bar"} 的 VS 2015 内部编译器错误

VS 2015 internal compiler error for static constexpr const char* a[] = {"foo", "bar"}

编译正常:

static constexpr char* a[] = {"foo", "bar"};

这有一个内部错误 (C1001) 要求我关闭优化,知道为什么吗? https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(C1001)&rd=true

static constexpr const char* a[]  = {"foo", "bar"};

这也编译:

static constexpr const char* const a[] = {"foo", "bar"};

None 两个编译的数组有一个可通过索引访问的数组。

解决方案是想出一个变通办法,直到 Microsoft 修复该错误。看起来 Constexpr 有一些问题预计会在 VS 2015 更新 2 中修复。https://blogs.msdn.microsoft.com/vcblog/2015/12/02/constexpr-in-vs2015-update-1/ https://blogs.msdn.microsoft.com/vcblog/2015/12/01/visual-studio-2015-update-1-is-here/#comments