[Clang] Linker error at -O0 due to missing static const int definition, hidden at -O2 #139227
Labels
clang:codegen
IR generation bugs: mangling, exceptions, etc.
diverges-from:msvc
Does the clang frontend diverge from msvc on this issue
In
Clang 20.1.0
, a class with static const int members that are declared but not defined results in a linker error at-O0
, but compiles successfully at-O2
.This seems to be due to constant propagation at higher optimization levels, which removes the need for symbol resolution, masking the fact that a required definition is missing.
This behavior differs from
MSVC
, which compiles successfully in both optimization levels.Code:
Reproduction Link: https://godbolt.org/z/dTdxWzMjP
The text was updated successfully, but these errors were encountered: