Skip to content
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

<variant>: Failed to use an empty class as template parameter #5254

Open
DuKeM-CSGO opened this issue Jan 27, 2025 · 2 comments
Open

<variant>: Failed to use an empty class as template parameter #5254

DuKeM-CSGO opened this issue Jan 27, 2025 · 2 comments
Labels
bug Something isn't working compiler Compiler work involved modules C++23 modules, C++20 header units

Comments

@DuKeM-CSGO
Copy link

DuKeM-CSGO commented Jan 27, 2025

Describe the bug

To compile the following file:

  1. Comment line 1 module; and line 4 export module Module; so that don't treat this file as an interface module unit and compile successfully.
  2. Uncomment line 7 int a; to add a member to class Dummy and compile successfully.

Or it can't be compiled due to internal compiler error.

Command-line test case

repro.ixx

module;
#include <variant>

export module Module;

struct Dummy{
	//int a;
};

using WrappedDummy = std::variant<Dummy>;

template<const WrappedDummy&>
struct Container {};

constexpr auto nttp = WrappedDummy{};

constexpr auto var = Container<nttp>{};
C:\Temp>cl /std:c++latest .\repro.ixx
Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34436 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.

.\repro.ixx(18): fatal error C1001: Internal compiler error.
(compiler file 'msc1.cpp', line 1599)
 To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com 
Please choose the Technical Support command on the Visual C++ 
 Help menu, or open the Technical Support help file for more information
INTERNAL COMPILER ERROR in 'H:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\CL.exe'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information

Expected behavior

compile successfully

STL version

Microsoft Visual Studio Community 2022
Version 17.12.4
@StephanTLavavej StephanTLavavej added bug Something isn't working compiler Compiler work involved modules C++23 modules, C++20 header units labels Jan 29, 2025
@StephanTLavavej
Copy link
Member

Thanks for the bug report! ICEs are always compiler bugs by definition, so let's ping @cdacamar.

@StephanTLavavej
Copy link
Member

Cameron believes that this is a duplicate of DevCom-10736790 (internal VSO-2238628) "Reference NTTPs broken in modules (ICE)", which is a bug in constexpr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Compiler work involved modules C++23 modules, C++20 header units
Projects
None yet
Development

No branches or pull requests

2 participants