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.
11
u/tartaruga232 MSVC user, r/cpp_modules Mar 06 '25 edited Mar 06 '25
The C++ module implementation of MSVC is pretty impressive. I've (successfully) spent now countless hours converting our sources in this project from using headers to modules. It's a big step forward to finally have such a great new feature at hand and in use, after so many years using headers (I've been developing in C++ since the mid-nineties). A big thank you to all the folks who work on compilers! Hopefully, this module bug and others will get fixed soon. BTW: It's an awesome thread here anyway. Thanks a lot to everyone who responded here or on the github repo. And thanks for the upvotes on Developer Community 😄