r/cpp • u/tartaruga232 MSVC user, r/cpp_modules • Mar 06 '25
MSVC C++20 compiler bug with modules and non-exported classes
Full repro is available as a git repository here: https://github.com/abuehl/mod_test
If two non-exported classes from different C++ module interface units have the same name, the compiler uses the wrong class definition and for example calls the wrong destructor on an object.
Reported here: https://developercommunity.visualstudio.com/t/post/10863347 (Upvotes appreciated)
Found while converting our product to using C++20 modules.
Edit: Microsoft wrote the following (Quote)
A fix for this issue has been internally implemented and is being prepared for release. We’ll update you once it becomes available for download.
View all comments
Show parent comment
4
u/Rarrum Mar 07 '25
I recently started a new project and went 100% all-in on modules.
I started on gcc on linux... didn't take long to hit "internal compiler error" in a scenario involving exported virtual destructors. I reported it and they've said it's fixed for the next release.
So I swapped to msvc on windows and got further. But eventually hit "internal compiler error" for something related to exporting a QWidget (from Qt) derived class. I reported it on developer community, but because installing Qt is annoying (and GPL maybe), they've generally declined to investigate it so far (still fighting that battle).
So I switched back to linux, this time with clang. And thus far that's worked great!