public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/41510]  New: C++0x std::complex vs. initialization lists
@ 2009-09-30  1:47 bkoz at gcc dot gnu dot org
  2009-09-30  1:48 ` [Bug libstdc++/41510] " bkoz at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2009-09-30  1:47 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3873 bytes --]

Here is a sketch of what C++0x std::complex might look like. Minus, of course,
constexpr. Also included in the patch is a testfile that does the usual
init_list tests on std::complex overloads.

It fails to compile, with ambiguous overloads. As so:

%$bld/H-x86-gcc.20090927/bin/g++ -std=gnu++0x -g -O2
testsuite/26_numerics/complex/complex_init.cc 
testsuite/26_numerics/complex/complex_init.cc: In function ‘void
check_copy_list_initialization() [with _Tp = float]’:
testsuite/26_numerics/complex/complex_init.cc:33:41:   instantiated from here
testsuite/26_numerics/complex/complex_init.cc:18:42: error: call of overloaded
‘complex(<brace-enclosed initializer list>)’ is ambiguous
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1458:3:
note: candidates are: std::complex<float>::complex(const std::complex<long
double>&)
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1454:3:
note:                 std::complex<float>::complex(const std::complex<double>&)
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1020:5:
note:                 std::complex<float>::complex(const std::complex<float>&)
testsuite/26_numerics/complex/complex_init.cc: In function ‘void
check_copy_list_initialization() [with _Tp = double]’:
testsuite/26_numerics/complex/complex_init.cc:34:42:   instantiated from here
testsuite/26_numerics/complex/complex_init.cc:18:42: error: call of overloaded
‘complex(<brace-enclosed initializer list>)’ is ambiguous
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1462:3:
note: candidates are: std::complex<double>::complex(const std::complex<long
double>&)
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1176:7:
note:                 std::complex<double>::complex(const std::complex<float>&)
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1164:5:
note:                 std::complex<double>::complex(const
std::complex<double>&)
testsuite/26_numerics/complex/complex_init.cc: In function ‘void
check_copy_list_initialization() [with _Tp = long double]’:
testsuite/26_numerics/complex/complex_init.cc:35:47:   instantiated from here
testsuite/26_numerics/complex/complex_init.cc:18:42: error: call of overloaded
‘complex(<brace-enclosed initializer list>)’ is ambiguous
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1324:7:
note: candidates are: std::complex<long double>::complex(const
std::complex<double>&)
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1321:7:
note:                 std::complex<long double>::complex(const
std::complex<float>&)
/mnt/disk/dolores/mnt/share/bld/H-x86-gcc.20090927/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/complex:1309:5:
note:                 std::complex<long double>::complex(const
std::complex<long double>&)


It's hard to tell w/o the constexpr overloads in. Thoughts?

-benjamin


-- 
           Summary: C++0x std::complex vs. initialization lists
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bkoz at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/41510] C++0x std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
@ 2009-09-30  1:48 ` bkoz at gcc dot gnu dot org
  2010-05-22  8:07 ` [Bug libstdc++/41510] [C++0x] " paolo dot carlini at oracle dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2009-09-30  1:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bkoz at gcc dot gnu dot org  2009-09-30 01:48 -------
Created an attachment (id=18667)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18667&action=view)
c++0x test for std::complex


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
  2009-09-30  1:48 ` [Bug libstdc++/41510] " bkoz at gcc dot gnu dot org
@ 2010-05-22  8:07 ` paolo dot carlini at oracle dot com
  2010-05-22 15:32 ` gdr at cs dot tamu dot edu
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-22  8:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2010-05-22 08:07 -------
Jason, can you have a look to the errors due to the ambiguous overloading
pointed out by Benjamin? Happen for this type of copy initialization:

  std::complex<value_type> z4 = {1.1, 2.2};

where value_type is either float, double or long double. I'm not at all sure we
are supposed to accept that in C++0x...

PS: as regards the patchlet to <complex> itself, I don't think is correct: in
C++0x too, as in C++03, explicit applies only to the constructors taking a
"wider" complex type to construct a "narrower" complex type, eg. constructing
complex<double> from complex<long double> is explicit, from complex<float> is
not.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
  2009-09-30  1:48 ` [Bug libstdc++/41510] " bkoz at gcc dot gnu dot org
  2010-05-22  8:07 ` [Bug libstdc++/41510] [C++0x] " paolo dot carlini at oracle dot com
@ 2010-05-22 15:32 ` gdr at cs dot tamu dot edu
  2010-05-22 20:22 ` paolo dot carlini at oracle dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gdr at cs dot tamu dot edu @ 2010-05-22 15:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from gdr at cs dot tamu dot edu  2010-05-22 15:32 -------
Subject: Re:  [C++0x] std::complex vs. initialization lists

"paolo dot carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org> writes:

| Jason, can you have a look to the errors due to the ambiguous overloading
| pointed out by Benjamin? Happen for this type of copy initialization:
| 
|   std::complex<value_type> z4 = {1.1, 2.2};
| 
| where value_type is either float, double or long double. I'm not at all sure
we
| are supposed to accept that in C++0x...

if this ambiguity has anything to do with the constructors for
_Complex T, I think we can remove them and instead define a
free-standing function that would do the conversion with reinterpret
casts. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-05-22 15:32 ` gdr at cs dot tamu dot edu
@ 2010-05-22 20:22 ` paolo dot carlini at oracle dot com
  2010-05-23  2:13 ` [Bug c++/41510] " jason at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-22 20:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2010-05-22 20:21 -------
Hi Gaby: actually, I don't think it does, see the error messages above, which
are still up to date, as far as I can see. I will double check, anyway, and if
I notice something new I'll let you know asap. Thanks!


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-05-22 20:22 ` paolo dot carlini at oracle dot com
@ 2010-05-23  2:13 ` jason at gcc dot gnu dot org
  2010-05-23  9:28 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-23  2:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2010-05-23 02:13 -------
This seems pretty clearly a compiler bug; it only occurs in template context. 
In a non-template function there is no error.  That is, this works:

#include <complex>
void f()
{
  std::complex<float> z4 = {1.1, 2.2};
}

but this doesn't:

#include <complex>
template <class T> void f()
{
  std::complex<float> z4 = {1.1, 2.2};
}

template void f<int>();


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
          Component|libstdc++                   |c++
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-05-23 02:13:32
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-05-23  2:13 ` [Bug c++/41510] " jason at gcc dot gnu dot org
@ 2010-05-23  9:28 ` paolo dot carlini at oracle dot com
  2010-05-24 18:38 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-23  9:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2010-05-23 09:27 -------
Crazy, thanks for looking into it.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-05-23  9:28 ` paolo dot carlini at oracle dot com
@ 2010-05-24 18:38 ` jason at gcc dot gnu dot org
  2010-05-24 20:33 ` jason at gcc dot gnu dot org
  2010-05-24 20:33 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-24 18:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2010-05-24 18:38 -------
Subject: Bug 41510

Author: jason
Date: Mon May 24 18:38:16 2010
New Revision: 159792

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159792
Log:
        PR c++/41510
        * decl.c (check_initializer): Don't wrap an init-list in a
        TREE_LIST.
        * init.c (build_aggr_init): Don't assume copy-initialization if
        init has CONSTRUCTOR_IS_DIRECT_INIT.
        * call.c (build_new_method_call): Sanity check.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/initlist35.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/init/brace6.C


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2010-05-24 20:33 ` jason at gcc dot gnu dot org
@ 2010-05-24 20:33 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-24 20:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2010-05-24 20:33 -------
Fixed for 4.5.1.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.5.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/41510] [C++0x] std::complex vs. initialization lists
  2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2010-05-24 18:38 ` jason at gcc dot gnu dot org
@ 2010-05-24 20:33 ` jason at gcc dot gnu dot org
  2010-05-24 20:33 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-24 20:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jason at gcc dot gnu dot org  2010-05-24 20:33 -------
Subject: Bug 41510

Author: jason
Date: Mon May 24 20:33:06 2010
New Revision: 159796

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159796
Log:
        PR c++/41510
        * decl.c (check_initializer): Don't wrap an init-list in a
        TREE_LIST.
        * init.c (build_aggr_init): Don't assume copy-initialization if
        init has CONSTRUCTOR_IS_DIRECT_INIT.
        * call.c (build_new_method_call): Sanity check.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/cpp0x/initlist35.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/call.c
    branches/gcc-4_5-branch/gcc/cp/decl.c
    branches/gcc-4_5-branch/gcc/cp/init.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/init/brace6.C


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41510


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-05-24 20:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-30  1:47 [Bug libstdc++/41510] New: C++0x std::complex vs. initialization lists bkoz at gcc dot gnu dot org
2009-09-30  1:48 ` [Bug libstdc++/41510] " bkoz at gcc dot gnu dot org
2010-05-22  8:07 ` [Bug libstdc++/41510] [C++0x] " paolo dot carlini at oracle dot com
2010-05-22 15:32 ` gdr at cs dot tamu dot edu
2010-05-22 20:22 ` paolo dot carlini at oracle dot com
2010-05-23  2:13 ` [Bug c++/41510] " jason at gcc dot gnu dot org
2010-05-23  9:28 ` paolo dot carlini at oracle dot com
2010-05-24 18:38 ` jason at gcc dot gnu dot org
2010-05-24 20:33 ` jason at gcc dot gnu dot org
2010-05-24 20:33 ` jason at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).