This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/40942] New: GCC accepts code that Comeau and MSVC deems invalid.


The following test case compiles with GCC, it chooses the second ctor. Both
MSVC8 and Comeau reject it complaining about overload ambiguity.


#include <cstdlib>

template <bool B, class T = void>
struct enable_if_c {
  typedef T type;
};

template <class T>
struct enable_if_c<false, T> {};

template <class Cond, class T = void>
struct enable_if : public enable_if_c<Cond::value, T> {};


struct true_type
{
  enum { value = 1 };
};


struct false_type
{
  enum { value = 0 };
};


template <typename T, typename U>
struct is_same
  : public false_type
{ };


template <typename T>
struct is_same<T, T>
  : public true_type
{ };


struct S
{
  template <typename T>
  S (T const *,
     typename enable_if<is_same<char, T>, T *>::type = 0)
  { }

  template <size_t N>
  S (char const (&)[N])
  { }
};

int
main()
{
  char array[] = "test";

  S s1 ("test");
  S s2 (array);
}


-- 
           Summary: GCC accepts code that Comeau and MSVC deems invalid.
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: v dot haisman at sh dot cvut dot cz
 GCC build triplet: x86_64-portbld-freebsd7.1
  GCC host triplet: x86_64-portbld-freebsd7.1
GCC target triplet: x86_64-portbld-freebsd7.1


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]