[Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Aug 18 13:12:00 GMT 2011


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-18 13:10:55 UTC ---
(Obviously it shouldn't crash the compiler, but ...)

you probably don't want  to use std::make_pair<X, Y> in C++0x, i.e. with an
explicit template argument list.  The definition of make_pair has changed, and
it doesn't do what you might think it does.

The sole purpose of make_pair is to deduce its argument types.  If you want to
defeat type deduction by specifying the types, just say:

  std::pair<int, std::ofstream> p(int(), std::ofstream());



More information about the Gcc-bugs mailing list