martin krastev via llvm-dev
2019-Feb-09 16:12 UTC
[llvm-dev] bogus field designator error returned by front-end
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190209/14ffa9c9/attachment.html>