public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40942]  New: GCC accepts code that Comeau and MSVC deems invalid.
@ 2009-08-02 14:48 v dot haisman at sh dot cvut dot cz
  2009-08-04 12:55 ` [Bug c++/40942] " jwakely dot gcc at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: v dot haisman at sh dot cvut dot cz @ 2009-08-02 14:48 UTC (permalink / raw)
  To: gcc-bugs

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


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

end of thread, other threads:[~2021-08-23  7:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40942-4@http.gcc.gnu.org/bugzilla/>
2012-03-29 13:43 ` [Bug c++/40942] GCC accepts code that Comeau and MSVC deems invalid redi at gcc dot gnu.org
2012-03-29 17:53 ` vhaisman at gmail dot com
2012-03-29 20:00 ` manu at gcc dot gnu.org
2012-03-30 16:20 ` dodji at gcc dot gnu.org
2012-03-31 17:07 ` dodji at seketeli dot org
2012-04-02  8:53 ` dodji at gcc dot gnu.org
2012-04-02  8:57 ` dodji at gcc dot gnu.org
2021-08-23  7:24 ` pinskia at gcc dot gnu.org
2009-08-02 14:48 [Bug c++/40942] New: " v dot haisman at sh dot cvut dot cz
2009-08-04 12:55 ` [Bug c++/40942] " jwakely dot gcc at gmail dot com
2009-08-25 13:25 ` bangerth at gmail dot com
2009-08-25 14:20 ` v dot haisman at sh dot cvut dot cz
2009-08-25 14:49 ` tom at kera dot name

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).