3

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.

cpplearner
  • 13,776
  • 2
  • 47
  • 72
noztol
  • 494
  • 6
  • 25
  • *"internal compiler error"* means a bug in the compiler. If you have a workaround, use that while waiting for the next compiler service pack. – Bo Persson Mar 12 '16 at 10:59
  • Just guessing here, but compiling with optimisations should logically be much harder to accomplish for the compiler than compiling without optimisations, so it's also more bug-prone. – Christian Hackl Mar 12 '16 at 11:09
  • Use connect.microsoft.com to file a bug report. – Hans Passant Mar 12 '16 at 12:47
  • I filed a bug: https://connect.microsoft.com/VisualStudio/feedback/details/2471252 – noztol Mar 14 '16 at 15:16
  • Wanted to Post an update that the bug on microsoft's end has been closed and marked fixed for vs2015 update 2. – noztol Apr 20 '16 at 19:05

1 Answers1

0

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

noztol
  • 494
  • 6
  • 25