1
votes

There is code

#include <array>

struct Foo {
  int bar;
};

int main() {
  constexpr auto v = std::array{Foo{}};
  return 0;
}

While compile whith C++17:

fatal error C1001: Internal compiler error. ... (compiler file 'msc1.cpp', line 1591) INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.27.29110\bin\HostX86\x86\CL.exe'

But this - compiles

#include <array>

struct Foo {
  int bar;
};

int main() {
  constexpr std::array<Foo, 1> v{Foo{}};
  return 0;
}

All optimizations are disabled as described here

Is this a compiler bug?

1
I'd say that internal compiler error is always a bug, even if the code that lead to it is invalid.Yksisarvinen

1 Answers

1
votes

This looks like the same bug reported on developercommunity.visualstudio.com under Regression: c++ internal compiler error in 16.7.0 with /std:c++17 (compiler file 'msc1.cpp', line 1591). I suggest you upvote that bug report, and keep an eye on it for possible resolutions.

The issue was introduced in the 16.7.0 update, and is not fixed as of the latest 16.7.5. Interim workarounds are to revert to 16.6.5, or drop /std:c++17 and use /std:default or /std:c++14 instead.