Skip to content

<typeinfo>: Error with import std; and typeid(T).name() - #3677

Merged
Stephan T. Lavavej (StephanTLavavej) merged 3 commits into
microsoft:mainfrom
StephanTLavavej:import-typeid
May 5, 2023
Merged

<typeinfo>: Error with import std; and typeid(T).name()#3677
Stephan T. Lavavej (StephanTLavavej) merged 3 commits into
microsoft:mainfrom
StephanTLavavej:import-typeid

Conversation

@StephanTLavavej

Copy link
Copy Markdown
Member

Cameron DaCamara (@cdacamar) explained that in this case, the MSVC compiler looks for the True Name of type_info in the global namespace, so we need to export it as a special exception.

I'm adding test coverage for this scenario. The using namespace std; in this test doesn't actually affect the repro, so I didn't bother to remove it.

Fixes DevCom-10349749 and internal VSO-1810086 / AB#1810086 .

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added bug Something isn't working modules C++23 modules, C++20 header units labels Apr 28, 2023
@strega-nil-ms

Copy link
Copy Markdown
Contributor

Is this conforming? I'm okay with "no, but it needs to not be conforming for our implementation", but I'm wondering if it'd be possible to make the compiler search in std:: here, rather than continuing the non-conformance.

@StephanTLavavej

Copy link
Copy Markdown
Member Author

Cameron DaCamara (@cdacamar) said on Discord:

I suppose I could change that, but I don't want to introduce a compatibility problem 😦

The Standardese that I wrote, N4944 [std.modules]/6, says:

Recommended practice: Implementations should avoid exporting any other declarations from the C++ library modules.

IMO it's slightly nonconforming to emit ::type_info because it could clash with user code, but the same is also true for classic <type_info> (it's not a reserved name, nor is it one of the C names that is in a superposition between global and std).

In practice I think it's easiest to just make this special exception and not worry about it further.

@CaseyCarter

Copy link
Copy Markdown
Contributor

I suppose I can live with this as extending our pre-existing non-conformance into the Modules Universe.

@StephanTLavavej

Copy link
Copy Markdown
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working modules C++23 modules, C++20 header units

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants