Testcase: _Complex float f(float x, float y) { _Complex float a = (_Complex float){x}; return a; }
Even _Complex double foo (double x) { return (_Complex double) x; } or _Complex double foo (double x) { return x; } does not work. But _Complex double foo (double x) { return x + 1.i; } does.
Subject: Re: C++ front-end rejects valid compound literal (with complex types) "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes: | Even | | _Complex double foo (double x) | { | return (_Complex double) x; | } | | or | | _Complex double foo (double x) | { | return x; | } | | does not work. But | | _Complex double foo (double x) | { | return x + 1.i; | } | | does. I believe there was a long thread about this for the C++ front-end. The issue is that _Complex is a new fundamental type, ttherefore needs elaboration about ordering conversion rules, including overload resolution. The issue was coumponded by the fact that C++ has a class template complex with slightly different rules. I don't remember what the conclusion was. -- Gaby
Fixed by the patch for bug 31780.