This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/40925] New: c++0x std::pair<T*,U*> constructor doesn't accept (0, 0)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]