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

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