-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"miscompilationneeds-reductionLarge reproducer that should be reduced into a simpler formLarge reproducer that should be reduced into a simpler form
Description
This semi-reduced code from: #95474 (comment)
struct MyStruct {
double m0{-9999.0};
int m1{-12345};
};
constexpr MyStruct default_val;
auto compute_area(double l, const MyStruct &val = default_val) -> double {
if (val.m1 == 1)
return 2.0;
return 0;
}
#include <cassert>
auto main() -> int {
MyStruct in_val{.m0 = 2.0, .m1 = 1};
double val = compute_area(1.0, in_val);
assert(val == 2.0);
}
crashes at runtime, it looks like due to VD->getAnyInitializer(VD)
pulling in the default value.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"miscompilationneeds-reductionLarge reproducer that should be reduced into a simpler formLarge reproducer that should be reduced into a simpler form