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: unassig...@gcc.gnu.org
        ReportedBy: stif...@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.

Reply via email to