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

             Bug #: 56450
           Summary: ICE with SFINAE when detecting non-static member
                    variable
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: d.f...@gmx.de


I tried to detect a non-static member variable of a given type and ran into an
ICE. Here's the code:

#include <type_traits>

template< typename, typename = void >
struct has_const_int_dummy
  : std::false_type
{};

template< typename T >
struct has_const_int_dummy< T, typename std::enable_if< std::is_same< decltype(
std::declval< T >().dummy ), const int >::value >::type >
  : std::true_type
{};

struct A0 { const int dummy; };
struct A1 {};
struct A2 { int dummy(); };
struct A3 { static const int dummy = 0; };

int main()
{
  static_assert( has_const_int_dummy< A0 >::value, "A0" );
  static_assert( !has_const_int_dummy< A1 >::value, "A1" );
  static_assert( !has_const_int_dummy< A2 >::value, "A2" );
  static_assert( !has_const_int_dummy< A3 >::value, "A3" ); // line 23
}

And here's the output from by shell:

frey@vbox$ clang++-3.2 -std=c++0x -O3 -Wall -Wextra t.cc -o t
frey@vbox$ g++-4.7 -std=c++0x -O3 -Wall -Wextra t.cc -o t
t.cc: In function ‘int main()’:
t.cc:23:44: internal compiler error: in finish_decltype_type, at
cp/semantics.c:5274
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cclJIlZs.out file, please attach this to
your bugreport.
frey@vbox$ 

As you can see, the code is accepted by clang. Also, the same error as with
g++-4.7 is also produced by g++-4.6, just the line number in cp/semantics.c is
different.

Reply via email to