Hi,
Apologies if I got the wrong list for what is essentially a bug report with the front-end.
The following code (godbolt: https://godbolt.org/z/lT4LIe) breaks with -DBREAKAGE and compiles without that macro:
struct Value {
union {
int i32;
float f32;
};
};
template < int >
Value foo()
{
int acc_i32 = 0;
float acc_f32 = 0;
bool isF32 = false;
#if BREAKAGE
if (isF32) {
const Value acc = { .f32 = acc_f32 };
return acc;
}
#endif
const Value acc = { .i32 = 32 /acc_i32/ };
return acc;
}
Value bar()
{
int acc_i32 = 0;
float acc_f32 = 0;
bool isF32 = false;
if (isF32) {
const Value acc = { .f32 = acc_f32 };
return acc;
}
const Value acc = { .i32 = acc_i32 };
return acc;
}
Value eval(const int a)
{
if (a)
return foo< 42 >(); // error: field designator (null) does not refer to any field in type…
else
return bar();
}
Please note that bar() does not exhibit the problem.
Best regards,
Martin