Search code examples
c++visual-studio-2015compiler-bug

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


this compiles fine:

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

this has an internal error (C1001) asking me to turn optimizations off, any ideas why? https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(C1001)&rd=true

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

this also compiles:

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

None of the two that compile have an array that's accessible via indexing.


Solution

  • The solution is to come up with a work around until microsoft fixes the bug. It looks like there are a few issues with Constexpr expected to be fixed in VS 2015 update 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