marzer / tomlplusplus

Header-only TOML config file parser and serializer for C++17.
https://marzer.github.io/tomlplusplus/
MIT License
1.47k stars 141 forks source link

Internal Compiler Error when including header in global module fragment (C++ 20 modules) #229

Open KeinNiemand opened 1 week ago

KeinNiemand commented 1 week ago

Environment

toml++ version and/or commit hash:
Commit Hash: 1f7884e59165e517462f922e7b6de131bd9844f3

Compiler:
MSVC 2019 Version 1940

C++ standard mode:
C++20

Target arch:
x64

Library configuration overrides:
None, using default configurations

Relevant compilation flags:

Describe the bug

When attempting to use the toml++ library within a C++20 module, I encounter an internal compiler error during compilation. The error seems to occur when the library header (toml.hpp) is included in the global module fragment of a C++20 module. The issue appears specific to scenarios where the library is included and utilized within the module definition.
The exact compiler error:

>Kompilieren...
1>TomlPlusPlus.ixx
1>\TomlPlusPlus.ixx(12,1): error C1001: Interner Compilerfehler.
1>\TomlPlusPlus.ixx(12,1): error C1001: (Compilerdatei "D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\module\writer.cpp", Zeile 6786)
1>\TomlPlusPlus.ixx(12,1): error C1001:  Um dieses Problem zu umgehen, vereinfachen oder ändern Sie das Programm im Umfeld der oben aufgeführten Positionen.
1>\TomlPlusPlus.ixx(12,1): error C1001: Geben Sie nach Möglichkeit hier Reproduktionsschritte an: https://developercommunity.visualstudio.com 
1>\TomlPlusPlus.ixx(12,1): error C1001: Wählen Sie im Menü "Hilfe" von Visual C++ den Befehl "Technischer Support",
1>\TomlPlusPlus.ixx(12,1): error C1001:  oder öffnen Sie die Hilfedatei des technischen Supports, um weitere Informationen zu erhalten.
1>Die Erstellung des Projekts "SharedCode.vcxproj" ist abgeschlossen -- FEHLER.

Steps to reproduce (or a small repro code sample)

  1. Set up a C++ project with C++20 and module support enabled in MSVC.
  2. Include toml++ using the global module fragment in a module file.
  3. Attempt to parse a TOML file using toml++ within a module's function.
  4. Compile the project, which triggers the internal compiler error.

Example code snippet:

cpp
module;
#include <toml.hpp>

export module Configuration;

export class Configuration {
public:
    void LoadFromFile(const std::string& filename) {
        auto config = toml::parse_file(filename);  // Usage of toml++
    }
};

Additional information

The internal compiler error is sound like a compiler bug with modules, but I have no idea what in toml++ breaks the compiler which I think is a reason why they ignored my report so far. When you include it in a c++20 module. Fixing this would require finding a workaround for whatever causes the internal compiler error, or maybe providing a c++20 module version of the library.

marzer commented 5 days ago

The exact compiler error:

~...can you post it in English?~, oh, wait, it's an ICE. I guess it is unlikely to say anything overly helpful, regardless of language 😅

You're not the first to have issues with modules and toml++: #172 Sadly I'm unlikely to find time to do anything about this. Can you share a link to your bug report ticket? That way I can at least track it, up-vote it, et cetera.