Bug 30209 - C++ front-end rejects valid compound literal (with complex types)
Summary: C++ front-end rejects valid compound literal (with complex types)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on: 21210
Blocks: 31338 31780
  Show dependency treegraph
 
Reported: 2006-12-14 05:21 UTC by Andrew Pinski
Modified: 2008-01-26 13:51 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2006-12-14 05:21:30 UTC
Testcase:
_Complex float f(float x, float y)
{
  _Complex float a = (_Complex float){x};
  return a;
}
Comment 1 Richard Biener 2006-12-14 11:21:22 UTC
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.
Comment 2 gdr@cs.tamu.edu 2006-12-14 16:30:01 UTC
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
Comment 3 Jason Merrill 2008-01-25 19:52:41 UTC
Fixed by the patch for bug 31780.