public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/40925]  New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0)
@ 2009-07-31 15:15 richard-gccbugzilla at metafoo dot co dot uk
  2009-07-31 15:26 ` [Bug libstdc++/40925] " richard-gccbugzilla at metafoo dot co dot uk
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: richard-gccbugzilla at metafoo dot co dot uk @ 2009-07-31 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

This expression:

  std::pair<T*, U*>(0, 0)

... compiles with -std=c++98, but does not compile with -std=c++0x. We have
tens, possibly hundreds, of such constructs in our codebase. Either this is a
libstdc++ bug or an (I think fairly serious) issue in the changes to std::pair
in the C++-0x working paper. If the types in question are known, this can be
worked around by using std::make_pair<T*,U*> instead of std::pair<T*,U*>. Cases
with no nice workaround include:

typedef std::map<T*, U> M;
// Later:
m.insert(M::value_type(0, x));

... and ...

std::pair<T*, U*> pair(0, 0);

The former case seems to have no workaround other than listing the types T* and
U again. The latter case can be worked around with auto, but we wish to keep
our code compiling with -std=c++98 too, for now, so I think we're reduced to
repeating the types T* and U*.

The compilation error is:

/usr/include/c++/4.4/bits/stl_pair.h: In constructor ‘std::pair<_T1,
_T2>::pair(_U1&&, _U2&&) [with _U1 = int, _U2 = int, _T1 = T*, _T2 = U*]’:
/usr/include/c++/4.4/bits/stl_pair.h:90: error: invalid conversion from ‘int’
to ‘T*’

Presumably the std::pair<T,U>::pair(T, U) constructor has been removed in
favour of this more "general" one?


-- 
           Summary: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0)
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: richard-gccbugzilla at metafoo dot co dot uk


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


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

* [Bug libstdc++/40925] c++0x std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
@ 2009-07-31 15:26 ` richard-gccbugzilla at metafoo dot co dot uk
  2009-07-31 15:29 ` paolo dot carlini at oracle dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: richard-gccbugzilla at metafoo dot co dot uk @ 2009-07-31 15:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from richard-gccbugzilla at metafoo dot co dot uk  2009-07-31 15:26 -------
Working draft N2914, 20.3.3 says:

template <VariableType T1, VariableType T2>
struct pair {
  [...]
  requires CopyConstructible<T1> && CopyConstructible<T2> pair(const T1 &x,
const T2 &y);

... and this is (modulo concept constraints) present in stl_pair.h, but I
imagine that an argument of 0 doesn't select this constructor.


-- 


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


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

* [Bug libstdc++/40925] c++0x std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
  2009-07-31 15:26 ` [Bug libstdc++/40925] " richard-gccbugzilla at metafoo dot co dot uk
@ 2009-07-31 15:29 ` paolo dot carlini at oracle dot com
  2009-07-31 16:14 ` [Bug libstdc++/40925] [c++0x] " paolo dot carlini at oracle dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-07-31 15:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2009-07-31 15:28 -------
These issues are known, and the specifications of std::pair for C++0x are in
flux. The updated specifications will be implemented in due course, when
sufficiently stable vs the removal of Concepts and the parallel changes to
std::map & co. Remember C++0x is an *experimental* mode, we make no guarantees.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug libstdc++/40925] [c++0x] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
                   ` (2 preceding siblings ...)
  2009-07-31 16:14 ` [Bug libstdc++/40925] [c++0x] " paolo dot carlini at oracle dot com
@ 2009-07-31 16:14 ` paolo dot carlini at oracle dot com
  2009-07-31 16:14 ` paolo dot carlini at oracle dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-07-31 16:14 UTC (permalink / raw)
  To: gcc-bugs



-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-07-31 16:14:10
               date|                            |


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


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

* [Bug libstdc++/40925] [c++0x] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
                   ` (3 preceding siblings ...)
  2009-07-31 16:14 ` paolo dot carlini at oracle dot com
@ 2009-07-31 16:14 ` paolo dot carlini at oracle dot com
  2009-09-18 13:47 ` joerg dot richter at pdv-fs dot de
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-07-31 16:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2009-07-31 16:14 -------
Waiting...


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED


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


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

* [Bug libstdc++/40925] [c++0x] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
  2009-07-31 15:26 ` [Bug libstdc++/40925] " richard-gccbugzilla at metafoo dot co dot uk
  2009-07-31 15:29 ` paolo dot carlini at oracle dot com
@ 2009-07-31 16:14 ` paolo dot carlini at oracle dot com
  2009-07-31 16:14 ` paolo dot carlini at oracle dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-07-31 16:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2009-07-31 16:13 -------
Let's suspend the issue, but anyway, has to wait for std::pair to stabilize a
bit in the Standard. To be clear, this is the original issue, which has been
filed after our original implementation of a previous Draft:

  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#811

Then came Concepts and fixed it in the Draft Standard. But now Concepts are
gone and std::pair is in flux anyway for other reasons (see, e.g n2908)...


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |
            Summary|c++0x std::pair<T*,U*>      |[c++0x] std::pair<T*,U*>
                   |constructor doesn't accept  |constructor doesn't accept
                   |(0, 0)                      |(0, 0)


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


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

* [Bug libstdc++/40925] [c++0x] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
                   ` (4 preceding siblings ...)
  2009-07-31 16:14 ` paolo dot carlini at oracle dot com
@ 2009-09-18 13:47 ` joerg dot richter at pdv-fs dot de
  2009-09-18 14:11 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: joerg dot richter at pdv-fs dot de @ 2009-09-18 13:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from joerg dot richter at pdv-fs dot de  2009-09-18 13:47 -------
I found Doug Gregors workaround for this pair problem:
http://gcc.gnu.org/ml/libstdc++/2008-10/msg00080.html

I wonder why it was reverted 9 days later?  I couldn't find any discussion on
gcc-patches nor libstdc++.  Perhaps I have missed something.  Was this patch
not good enough? 

The reason I ask is that I want to use C++0x.  Currently I do this with
"-std=gnu++0x -U__GXX_EXPERIMENTAL_CXX0X__"

I undefine __GXX_EXPERIMENTAL_CXX0X__ just because of the pair(0) problem.
But unfortunately this doesn't give me the library features of C++0x :(


-- 

joerg dot richter at pdv-fs dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joerg dot richter at pdv-fs
                   |                            |dot de


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


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

* [Bug libstdc++/40925] [c++0x] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
                   ` (5 preceding siblings ...)
  2009-09-18 13:47 ` joerg dot richter at pdv-fs dot de
@ 2009-09-18 14:11 ` paolo dot carlini at oracle dot com
  2009-10-29 19:26 ` [Bug libstdc++/40925] [c++0x] [DR811] " paolo at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-09-18 14:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2009-09-18 14:10 -------
(In reply to comment #5)
> I wonder why it was reverted 9 days later?  I couldn't find any discussion on
> gcc-patches nor libstdc++.  Perhaps I have missed something.

You did, it caused libstdc++/37919, as you can see in the ChangeLog. Really,
let's wait at least the Santa Cruz meeting to have a definite direction on DR
811...


-- 


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


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

* [Bug libstdc++/40925] [c++0x] [DR811] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
                   ` (6 preceding siblings ...)
  2009-09-18 14:11 ` paolo dot carlini at oracle dot com
@ 2009-10-29 19:26 ` paolo at gcc dot gnu dot org
  2009-10-30  2:29 ` paolo at gcc dot gnu dot org
  2010-02-08 11:07 ` paolo dot carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu dot org @ 2009-10-29 19:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from paolo at gcc dot gnu dot org  2009-10-29 19:26 -------
Subject: Bug 40925

Author: paolo
Date: Thu Oct 29 19:26:04 2009
New Revision: 153725

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153725
Log:
2009-10-29  Paolo Carlini  <paolo.carlini@oracle.com>

        PR libstdc++/40925
        * include/bits/stl_pair.h (pair<_T1, _T2>::pair(_U1&&, _U2&&)):
        Use enable_if to remove it from the overload set when either _U1
        is not convertible to _T1 or _U2 is not convertible to _T2.
        (pair<>::pair(_U1&&, _Arg0&&, _Args&&...)): Remove.

2009-10-29  Douglas Gregor  <doug.gregor@gmail.com>

        PR libstdc++/40925
        * testsuite/20_util/pair/40925.cc: Add.

Added:
    trunk/libstdc++-v3/testsuite/20_util/pair/40925.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_pair.h


-- 


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


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

* [Bug libstdc++/40925] [c++0x] [DR811] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
                   ` (7 preceding siblings ...)
  2009-10-29 19:26 ` [Bug libstdc++/40925] [c++0x] [DR811] " paolo at gcc dot gnu dot org
@ 2009-10-30  2:29 ` paolo at gcc dot gnu dot org
  2010-02-08 11:07 ` paolo dot carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu dot org @ 2009-10-30  2:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from paolo at gcc dot gnu dot org  2009-10-30 02:29 -------
Subject: Bug 40925

Author: paolo
Date: Fri Oct 30 02:29:14 2009
New Revision: 153733

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153733
Log:
2009-10-29  Paolo Carlini  <paolo.carlini@oracle.com>
            Douglas Gregor  <doug.gregor@gmail.com>

        PR libstdc++/40925 (again)
        * include/bits/stl_pair.h (pair<_T1, _T2>::pair(_U1&&, const _T2&),
        pair<_T1, _T2>::pair(const _T1&, _U2&&)): Add, to deal correctly
        with move-only types in the presence of "null pointers".
        * testsuite/20_util/pair/40925.cc: Extend.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_pair.h
    trunk/libstdc++-v3/testsuite/20_util/pair/40925.cc


-- 


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


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

* [Bug libstdc++/40925] [c++0x] [DR811] std::pair<T*,U*> constructor doesn't accept (0, 0)
  2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
                   ` (8 preceding siblings ...)
  2009-10-30  2:29 ` paolo at gcc dot gnu dot org
@ 2010-02-08 11:07 ` paolo dot carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-02-08 11:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from paolo dot carlini at oracle dot com  2010-02-08 11:07 -------
Can be closed (of course std::is_convertible needs front-end support, but
that's another story)


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|SUSPENDED                   |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.5.0


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


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

end of thread, other threads:[~2010-02-08 11:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-31 15:15 [Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0) richard-gccbugzilla at metafoo dot co dot uk
2009-07-31 15:26 ` [Bug libstdc++/40925] " richard-gccbugzilla at metafoo dot co dot uk
2009-07-31 15:29 ` paolo dot carlini at oracle dot com
2009-07-31 16:14 ` [Bug libstdc++/40925] [c++0x] " paolo dot carlini at oracle dot com
2009-07-31 16:14 ` paolo dot carlini at oracle dot com
2009-07-31 16:14 ` paolo dot carlini at oracle dot com
2009-09-18 13:47 ` joerg dot richter at pdv-fs dot de
2009-09-18 14:11 ` paolo dot carlini at oracle dot com
2009-10-29 19:26 ` [Bug libstdc++/40925] [c++0x] [DR811] " paolo at gcc dot gnu dot org
2009-10-30  2:29 ` paolo at gcc dot gnu dot org
2010-02-08 11:07 ` paolo dot carlini at oracle dot com

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).