Skip to content

ICE in clang++ 21.1.0 when using enum enumerator imported from header unit #155795

@RoqueDeicide

Description

@RoqueDeicide

Version

OS: Windows 10 22H2
LLVM: 21.1.0

Reproducer

test.h++

enum TestEnum
{
    TestEnumTest1
};

This file compiled with the following command without issue:

clang++ -std=c++26 -fmodule-header=user -x c++-header -o test.h++.pcm test.h++

test.c++m

export module test;
	
import "test.h++";

export enum Test
{
    TestValue = TestEnumTest1
};

This file, when compiled with the following command, produces an error:

clang++ -std=c++26 -fmodule-file=test.h++.pcm -x c++-module --precompile -o test.pcm test.c++m
test.c++m:4:2: warning: the implementation of header units is in an experimental phase [-Wexperimental-header-units]
    4 |         import "test.h++";
      |         ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang++ -std=c++26 -fmodule-file=test.h++.pcm -x c++-module --precompile -o test.pcm test.c++m
1.      <eof> parser at end of file
Exception Code: 0xC0000005
 #0 0x00007ff641aa8308 (C:\Program Files\LLVM\bin\clang++.exe+0x3768308)
 #1 0x00007ff641a825e8 (C:\Program Files\LLVM\bin\clang++.exe+0x37425e8)
 #2 0x00007ff641a853e3 (C:\Program Files\LLVM\bin\clang++.exe+0x37453e3)
 #3 0x00007ff641a936b6 (C:\Program Files\LLVM\bin\clang++.exe+0x37536b6)
 #4 0x00007ff641a8fd4d (C:\Program Files\LLVM\bin\clang++.exe+0x374fd4d)
 #5 0x00007ff641a8f1c8 (C:\Program Files\LLVM\bin\clang++.exe+0x374f1c8)
 #6 0x00007ff641a5d436 (C:\Program Files\LLVM\bin\clang++.exe+0x371d436)
 #7 0x00007ff641a5d608 (C:\Program Files\LLVM\bin\clang++.exe+0x371d608)
 #8 0x00007ff641a3cfc3 (C:\Program Files\LLVM\bin\clang++.exe+0x36fcfc3)
 #9 0x00007ff640278c85 (C:\Program Files\LLVM\bin\clang++.exe+0x1f38c85)
#10 0x00007ff63e9699b3 (C:\Program Files\LLVM\bin\clang++.exe+0x6299b3)
#11 0x00007ff63e9695fd (C:\Program Files\LLVM\bin\clang++.exe+0x6295fd)
#12 0x00007ff63e9662b6 (C:\Program Files\LLVM\bin\clang++.exe+0x6262b6)
#13 0x00007ff63e962e18 (C:\Program Files\LLVM\bin\clang++.exe+0x622e18)
#14 0x00007ff63e9616ae (C:\Program Files\LLVM\bin\clang++.exe+0x6216ae)
#15 0x00007ff63f24e18d (C:\Program Files\LLVM\bin\clang++.exe+0xf0e18d)
#16 0x00007ff63eaf1d75 (C:\Program Files\LLVM\bin\clang++.exe+0x7b1d75)
#17 0x00007ff63eaf1b68 (C:\Program Files\LLVM\bin\clang++.exe+0x7b1b68)
#18 0x00007ff63e816af5 (C:\Program Files\LLVM\bin\clang++.exe+0x4d6af5)
#19 0x00007ff63e81643e (C:\Program Files\LLVM\bin\clang++.exe+0x4d643e)
#20 0x00007ff63e81601d (C:\Program Files\LLVM\bin\clang++.exe+0x4d601d)
#21 0x00007ff63e80cd56 (C:\Program Files\LLVM\bin\clang++.exe+0x4ccd56)
#22 0x00007ff63e80a2f3 (C:\Program Files\LLVM\bin\clang++.exe+0x4ca2f3)
#23 0x00007ff64032bdd0 (C:\Program Files\LLVM\bin\clang++.exe+0x1febdd0)
#24 0x00007ff8c9a77374 (C:\Windows\System32\KERNEL32.DLL+0x17374)
#25 0x00007ff8cb05cc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 21.1.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
clang++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: *REDACTED*\test-584ffe.cppm
clang++: note: diagnostic msg: *REDACTED*\test-584ffe.sh
clang++: note: diagnostic msg:

********************

Files mentioned in the above log are:
test-584ffe.cppm

# 1 "test.c++m"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 483 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test.c++m" 2

 export module test;

 import ".\\test.h++";


 export enum Test
 {
  TestValue = TestEnumTest1
 };

test-584ffe.sh

# Crash reproducer for clang version 21.1.0
# Driver args: "--driver-mode=g++" "-std=c++26" "-fmodule-file=test.h++.pcm" "-x" "c++-module" "--precompile" "-o" "test.pcm" "test.c++m"
# Original command:  "C:\\Program Files\\LLVM\\bin\\clang++.exe" "-cc1" "-triple" "x86_64-pc-windows-msvc19.44.35214" "-emit-module-interface" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "test.c++m" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=none" "-relaxed-aliasing" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-fms-volatile" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-fdebug-compilation-dir=D:\\Code\\clang21_header_unit_define_ICE" "-fcoverage-compilation-dir=D:\\Code\\clang21_header_unit_define_ICE" "-resource-dir" "C:\\Program Files\\LLVM\\lib\\clang\\21" "-internal-isystem" "C:\\Program Files\\LLVM\\lib\\clang\\21\\include" "-internal-isystem" "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.44.35207\\include" "-internal-isystem" "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.44.35207\\atlmfc\\include" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.26100.0\\ucrt" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.26100.0\\shared" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.26100.0\\um" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.26100.0\\winrt" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.26100.0\\cppwinrt" "-std=c++26" "-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length=120" "-fno-use-cxa-atexit" "-fms-extensions" "-fms-compatibility" "-fms-compatibility-version=19.44.35214" "-fno-implicit-modules" "-fmodule-file=test.h++.pcm" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-o" "test.pcm" "-x" "c++" "test.c++m"
 "C:\\Program Files\\LLVM\\bin\\clang++.exe" "-cc1" "-triple" "x86_64-pc-windows-msvc19.44.35214" "-emit-module-interface" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "test.c++m" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=none" "-relaxed-aliasing" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-fms-volatile" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-fdebug-compilation-dir=D:\\Code\\clang21_header_unit_define_ICE" "-fcoverage-compilation-dir=D:\\Code\\clang21_header_unit_define_ICE" "-std=c++26" "-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length=120" "-fno-use-cxa-atexit" "-fms-extensions" "-fms-compatibility" "-fms-compatibility-version=19.44.35214" "-fno-implicit-modules" "-fmodule-file=test.h++.pcm" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-x" "c++" "test-584ffe.cppm"

Other Details

The crash is not occurring on LLVM 20.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:modulesC++20 modules and Clang Header Modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions