-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Modules TS] MSVC std library produces ambiguous type_info reference when including module with ms-compatibility #38400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note: The same exact code with header based declarations works fine. |
I believe I have tracked down the root issue. It seems that when I initialize the Sema under MSVCCompat it is adding the "predefined C++ types" which includes 'type_info' [llvm\tools\clang\lib\Sema\Sema.cpp 250]. Then, when the precompiled module is being generated it saves these type declarations. The issue comes when we load of the Sema a second time for the call to compile the exe with the extra module file. The Sema initialize again adds these hard coded types and when the name lookup for the 'type_name' identifier is used it cannot figure out that the two instances it is see are both from the implicit types since that info is lost when passing through the pcm. I do not have enough knowledge of the code to determine what the correct fix is. Do we 1) remove these hard coded types 2) prevent the ASTWriter from writing these to the pcm 3) add extra checks that we only add these types if they do not exist already in a AST file or 4) find a way to resolve these duplicate declarations? Note: I was able to build fine by removing these types from initialize. |
I am able to work around he issue for now by forcing -fno-ms-compatibility. However this issue still blocks all msvc work with modules. |
We have a set of "predefined" declarations that we use for tracking such declarations across translation units. (See PredefinedDeclIDs in include/clang/Serialization/ASTBitCodes.h.) We should be tracking this in the same way we track the other things on that list. |
I had the exact same issue in 2022, using There's some notice about this bug? |
Just for referencing/linking. I found this related issue with LLVM and C++ modules: #58532 |
I'm fairly certain that this is caused by a clang/module bug with |
Extended Description
When compiling an project on windows using the MSVC standard library I get an ambiguous reference to type_info:
I have attached an archive of the most simple repro of the issue. It also includes the ii file from save-temps.
Error Message:
In file included from main.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\istream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\ostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\ios:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\xlocnum:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\streambuf:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\xiosbase:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\xlocale:8:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\stdexcept:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\exception:27:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\vcruntime_exception.h:10:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\eh.h:52:14: error:
reference to 'type_info' is ambiguous
type_info const& _Type,
^
note: candidate found by name lookup is 'type_info'
note: candidate found by name lookup is 'type_info'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\eh.h:52:14: error:
reference to 'type_info' is ambiguous
note: candidate found by name lookup is 'type_info'
note: candidate found by name lookup is 'type_info'
The text was updated successfully, but these errors were encountered: