[Bug c++/60105] New: [C++11] g++ segfault on enable_if explicit cast operator

2014-02-06 Thread Andrey.E.Antipov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60105

Bug ID: 60105
   Summary: [C++11] g++ segfault on enable_if explicit cast
operator
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: Andrey.E.Antipov at gmail dot com

g++ segfaults on enable_if explicit cast operator. 
The code below crashes on gcc-4.8.2 on a mac with 
$ g++-4.8 a.cpp -std=c++11 -o ./a

a.cpp: In function 'int main()':
a.cpp:16:18: internal compiler error: Segmentation fault: 11
 std::cout <<  << std::endl; // This causes a crash
  ^

a.cpp:16:18: internal compiler error: Abort trap: 6
g++-4.8: internal compiler error: Abort trap: 6 (program cc1plus)
Abort trap: 6


---
#include 
#include 

template 
struct subclass {
template ::value>::type> 
explicit operator int(){return 1;};

operator V(){return 2.;}
friend std::ostream& operator<<(std::ostream&out, const subclass p){out <<
3; return out;}
};

int main()
{
subclass ;
subclass ;

std::cout <<  << std::endl; // This causes a crash
std::cout <<  << std::endl;
std::cout << int() << std::endl;
std::cout << int() << std::endl;
}

-
Commenting out the std::cout <<  << std::endl or removing "explicit"
keyword results in successful compilation and 3
3
2
1 
output as expected. 

g++-4.8 is 
$ g++-4.8 -v
Using built-in specs.
COLLECT_GCC=g++-4.8
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc48/4.8.2/libexec/gcc/x86_64-apple-darwin13.0.0/4.8.2/lto-wrapper
Target: x86_64-apple-darwin13.0.0
Configured with: ../configure --build=x86_64-apple-darwin13.0.0
--prefix=/usr/local/Cellar/gcc48/4.8.2 --enable-languages=c,c++,objc,obj-c++
--program-suffix=-4.8 --with-gmp=/usr/local/opt/gmp4
--with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08
--with-cloog=/usr/local/opt/cloog018 --with-isl=/usr/local/opt/isl011
--with-system-zlib --enable-version-specific-runtime-libs
--enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release
--enable-lto --disable-werror --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 4.8.2 (GCC)


[Bug c++/60105] [C++11] g++-4.8.2 segfaults on enable_if explicit cast operator

2014-02-07 Thread Andrey.E.Antipov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60105

--- Comment #1 from Andrey Antipov  ---
Tested - crashes on 4.7.3 and 4.7.2 on linux as well.