Visual C Internal Compiler Error

Started by UnderPlayer, 20 July 2019, 14:54:50

UnderPlayer

Hi fellow programmers, artists and humans,

today - experiencing the calmness and beauty of modern programming in C++ - I stumbled upon something. "What was it?" you might ask. And my answer would be: I don't know. It was just there and I had no clue where it came from or what it means. My compiler would give me an oddly unspecific error that reads "Internal Compiler Error". So after a short investigation I came to the conclusion that I still had no idea.

Okay, I will stop that now and give some specific information including a minimal example, that reproduces the error for me.
C++ 17
SFML: 2.5.1
TGUI: 0.8.5
Visual C: 14.21.27702
Visual Studio 2019 16.1.6
Build Config: Debug and Release

The error message (partly, because most of it is german in my case. It just says try contacting microsofts support hotline or change the code in some way.):

Error C1001 Internal Compilererror.
(Compilerfile "d:\agent\_work\4\s\src\vctools\Compiler\CxxFE\sl\p1\c\PackExpander.cpp", line 1764)
MenuItemTest C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\TGUI\SignalImpl.hpp 148


Code (cpp) Select

#include <TGUI/TGUI.hpp>

int main()
{
auto menu = tgui::MenuBar::create();
menu->addMenuItem({ "Test" }, true);
menu->connectMenuItem(
{ "Test" },
[]() { printf_s("works\n"); }
);
}


I'm quite sure that the function used to work for me, but now it does not anymore. I've never encountered that error before and my first bet would be, that something is off, so that the compiler doesn't know how to interpret the code in front of it.

Anyway, I hope someone here has an idea or maybe someone encountered the same problem and knows a solution.

Lars

UnderPlayer

#1
I just found this
If the file has a cxxfe or c1xx path segment, or is msc1.cpp, it is probably a parser error.
on the msdn page. Does that mean that the code is correct but something in the C++ Parser compiler code is wrong? Does the error occur on microsoft's side?

MSDN source:
https://docs.microsoft.com/de-de/cpp/error-messages/compiler-errors-1/fatal-error-c1001?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DDE-DE%26k%3Dk(C1001)%26rd%3Dtrue&view=vs-2019

I just realised that I am using C++ 17 but I did not build tgui with TGUI_USE_CPP17

texus

This does look like a bug in the compiler itself. It isn't the first time the signal code has given issues with different compilers (I had compile issues with GCC, clang an VC++), but these were all solved before the new signal code was released. So it seems like they changed something in VS2019 which causes it to fail to parse the code properly. Technically this is not an issue with my code (unless it turns out I would be using code that isn't compliant with the c++ standard which shouldn't be the case here) and it should be fixed by the compiler developers.
The only thing that can be done from my side is rewrite the code a little bit in the hope that the compiler suddenly supports it (the other compiler issues were also solved that way, by simplifying the code, such as turning one long line into two lines).

TGUI_USE_CPP17 is not something you need to define. I couldn't use c++17 code in TGUI for compatibility reasons but I still wanted to play around with c++17 so I added some code behind the undocumented TGUI_USE_CPP17 define. If the error you got would have been inside part of the code where a c++17 alternative was available then it could have just been solved by defining it, but that isn't the case here.

Line 148 in SignalImpl.hpp is on a opening brace, so it is hard to say if it fails on the line above or below, but I would guess it is on the line above. Could you try changing "decltype(auto)" on line 147 to "std::function<void()>" (and maybe also on line 155) and maybe also change the "{}" to "()" after index_sequence_for on line 149 to see if it compiles with these changes?
If it still doesn't compile after these changes then there isn't much I can do, I don't see any other ways to simplify that code more. It compiles fine with all other compilers, so it would be something that VS2019 needs to solve.

UnderPlayer

Okay, that is what I guessed :(. It does say it's something with the PackExpander or the filename let's me assume that.
I would try to create a minimal example for Microsoft, would you mind if I copy a bit of your code for that?
I would copy most parts of the binder and send a request to Mircosoft.

texus