Skip to content

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

Open
@DuKeM-CSGO

Description

@DuKeM-CSGO

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerCompiler work involvedmodulesC++23 modules, C++20 header units

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions