public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50117] New: Segmentation fault when using std::make_pair with std::ofstream and c++0x
@ 2011-08-18 12:28 stiffy2 at gmx dot de
  2011-08-18 13:11 ` [Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: stiffy2 at gmx dot de @ 2011-08-18 12:28 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50117
           Summary: Segmentation fault when using std::make_pair with
                    std::ofstream and c++0x
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: stiffy2@gmx.de


Created attachment 25052
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25052
preprocessed file

GCC 4.7 (revision 177825) triggers a segmentation fault when compiling the
following source code.

#include <fstream>

int main()
{
    std::make_pair<int, std::ofstream>(int(), std::ofstream());
}

Call to g++ including version, segfault at the end of the output:

% LANG=C g++ -std=c++0x -save-temps -O0 -v crash.cpp
Using built-in specs.
COLLECT_GCC=/home/evnu/bin/g++
COLLECT_LTO_WRAPPER=/home/evnu/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-plugin --enable-cloog-backend=isl
--with-ppl --enable-__cxa_atexit --with-system-zlib --enable-shared
--enable-threads=posix --enable-languages=c,c++ --disable-multilib --enable-lto
--prefix=/home/evnu
Thread model: posix
gcc version 4.7.0 20110817 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-std=c++0x' '-save-temps' '-O0' '-v' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /home/evnu/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -E -quiet -v
-D_GNU_SOURCE crash.cpp -mtune=generic -march=x86-64 -std=c++0x -O0
-fpch-preprocess -o crash.ii
ignoring nonexistent directory
"/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0

/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu

/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward
 /home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include
 /usr/local/include
 /home/evnu/include
 /home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-std=c++0x' '-save-temps' '-O0' '-v' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /home/evnu/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -fpreprocessed
crash.ii -quiet -dumpbase crash.cpp -mtune=generic -march=x86-64 -auxbase crash
-O0 -std=c++0x -version -o crash.s
GNU C++ (GCC) version 4.7.0 20110817 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.7.0 20110817 (experimental), GMP version 5.0.2,
MPFR version 3.0.1-p4, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.7.0 20110817 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.7.0 20110817 (experimental), GMP version 5.0.2,
MPFR version 3.0.1-p4, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: fb48fe63ecd7a2f98d0d4819cab74782
In file included from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:65:0,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/char_traits.h:41,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:41,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/istream:40,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:40,
                 from crash.cpp:1:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:
In instantiation of `constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&)
[with _U1 = int, <template-parameter-2-2> = void, _T1 = int, _T2 =
std::basic_ofstream<char>]':
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:285:72:
  required from `constexpr std::pair<typename
std::__decay_and_strip<_T1>::__type, typename
std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 =
int, _T2 = std::basic_ofstream<char>, typename
std::__decay_and_strip<_T2>::__type = std::basic_ofstream<char>, typename
std::__decay_and_strip<_T1>::__type = int]'
crash.cpp:5:62:   required from here
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:132:45:
error: use of deleted function `std::basic_ofstream<char>::basic_ofstream(const
std::basic_ofstream<char>&)'
In file included from crash.cpp:1:0:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:588:11:
error: `std::basic_ofstream<char>::basic_ofstream(const
std::basic_ofstream<char>&)' is implicitly deleted because the default
definition would be ill-formed:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:588:11:
error: use of deleted function `std::basic_ostream<char>::basic_ostream(const
std::basic_ostream<char>&)'
In file included from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/istream:41:0,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:40,
                 from crash.cpp:1:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:57:11:
error: `std::basic_ostream<char>::basic_ostream(const
std::basic_ostream<char>&)' is implicitly deleted because the default
definition would be ill-formed:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:57:11:
error: use of deleted function `std::basic_ios<char>::basic_ios(const
std::basic_ios<char>&)'
In file included from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:45:0,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/istream:40,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:40,
                 from crash.cpp:1:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_ios.h:64:11:
error: `std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' is
implicitly deleted because the default definition would be ill-formed:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:788:5:
error: `std::ios_base::ios_base(const std::ios_base&)' is private
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_ios.h:64:11:
error: within this context
In file included from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/istream:41:0,
                 from
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:40,
                 from crash.cpp:1:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:57:11:
error: use of deleted function `std::basic_ios<char>::basic_ios(const
std::basic_ios<char>&)'
In file included from crash.cpp:1:0:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:588:11:
error: use of deleted function `std::basic_ios<char>::basic_ios(const
std::basic_ios<char>&)'
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:588:11:
error: use of deleted function `std::basic_filebuf<char>::basic_filebuf(const
std::basic_filebuf<char>&)'
In file included from crash.cpp:1:0:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:69:11:
error: `std::basic_filebuf<char>::basic_filebuf(const
std::basic_filebuf<char>&)' is implicitly deleted because the default
definition would be ill-formed:
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/streambuf:800:7:
error: `std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const
__streambuf_type&) [with _CharT = char, _Traits = std::char_traits<char>,
std::basic_streambuf<_CharT, _Traits>::__streambuf_type =
std::basic_streambuf<char>]' is private
/home/evnu/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/fstream:69:11:
error: within this context
crash.cpp: In function `int main()':
crash.cpp:5:62: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream
  2011-08-18 12:28 [Bug c++/50117] New: Segmentation fault when using std::make_pair with std::ofstream and c++0x stiffy2 at gmx dot de
@ 2011-08-18 13:11 ` paolo.carlini at oracle dot com
  2011-08-18 13:12 ` redi at gcc dot gnu.org
  2011-09-23 12:00 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-18 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-08-18
            Summary|Segmentation fault when     |[C++0x] Segmentation fault
                   |using std::make_pair with   |when using std::make_pair
                   |std::ofstream and c++0x     |with std::ofstream
     Ever Confirmed|0                           |1


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

* [Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream
  2011-08-18 12:28 [Bug c++/50117] New: Segmentation fault when using std::make_pair with std::ofstream and c++0x stiffy2 at gmx dot de
  2011-08-18 13:11 ` [Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream paolo.carlini at oracle dot com
@ 2011-08-18 13:12 ` redi at gcc dot gnu.org
  2011-09-23 12:00 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2011-08-18 13:12 UTC (permalink / raw)
  To: gcc-bugs

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());


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

* [Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream
  2011-08-18 12:28 [Bug c++/50117] New: Segmentation fault when using std::make_pair with std::ofstream and c++0x stiffy2 at gmx dot de
  2011-08-18 13:11 ` [Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream paolo.carlini at oracle dot com
  2011-08-18 13:12 ` redi at gcc dot gnu.org
@ 2011-09-23 12:00 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-23 12:00 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-23 11:47:00 UTC ---
Worksforme with r179116. It you see it again, please re-open, thanks.


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

end of thread, other threads:[~2011-09-23 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18 12:28 [Bug c++/50117] New: Segmentation fault when using std::make_pair with std::ofstream and c++0x stiffy2 at gmx dot de
2011-08-18 13:11 ` [Bug c++/50117] [C++0x] Segmentation fault when using std::make_pair with std::ofstream paolo.carlini at oracle dot com
2011-08-18 13:12 ` redi at gcc dot gnu.org
2011-09-23 12:00 ` paolo.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).