public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24915]  New: Overload errors generated without template instantiations for class member templates
@ 2005-11-17 17:26 nem3 at pitt dot edu
  2005-11-17 17:36 ` [Bug c++/24915] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: nem3 at pitt dot edu @ 2005-11-17 17:26 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1998 bytes --]

template<typename T>
struct is_int
{
  static const bool value = false;
};

template <>
struct is_int<int>
{
  static const bool value = true;
};

template <bool Cond, typename T = void>
struct enable_if
{};

template <typename T>
struct enable_if<true, T>
{ typedef T type; };

class test
{
public:
   template <typename T>
   typename enable_if<is_int<T>::value>::type func(T x)
   {}

   template <typename T>
   typename enable_if<!is_int<T>::value>::type func(T x)
   {}
};

fails to compile on 4.0.2 with
t2.cpp:29: error: ‘template<class T> typename enable_if<(! is_int<T>::value),
void>::type test::func(T)’ cannot be overloaded
t2.cpp:25: error: with ‘template<class T> typename enable_if<is_int<T>::value,
void>::type test::func(T)’

fails to compile on 3.4.2 with
t2.cpp:30: error: `template<class T> typename enable_if<(! is_int<T>::value),
void>::type test::func(T)' and `template<class T> typename enable_if<
is_int<T>::value, void>::type test::func(T)' cannot be overloaded

However the same two functions will compile when not defined as part of a class 

<insert the enable_if and is_int from above>

template <typename T>
typename enable_if<is_int<T>::value>::type func(T x)
{}

template <typename T>
typename enable_if<!is_int<T>::value>::type func(T x)
{}

both msvc7.1 and Comeau 4.3.3 will accept it. 

I don't think that this is duplicate of 15882.

The problem appears to be that syntax checking is catching this before SFINAE
has a chance to prune the overload set. At any rate there are not template
instantiations in the test case.


-- 
           Summary: Overload errors generated without template
                    instantiations for class member templates
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nem3 at pitt dot edu


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


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

end of thread, other threads:[~2006-02-01 11:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
2005-11-17 17:36 ` [Bug c++/24915] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-11-19  2:19 ` mmitchel at gcc dot gnu dot org
2005-11-23  5:22 ` [Bug c++/24915] [3.4/4.0/4.1/4.2 " bangerth at dealii dot org
2005-12-12 22:39 ` reichelt at gcc dot gnu dot org
2005-12-20  2:01 ` mmitchel at gcc dot gnu dot org
2005-12-20  4:36 ` mmitchel at gcc dot gnu dot org
2005-12-20  4:39 ` mmitchel at gcc dot gnu dot org
2005-12-20  4:44 ` mmitchel at gcc dot gnu dot org
2005-12-20  4:49 ` [Bug c++/24915] [3.4 " mmitchel at gcc dot gnu dot org
2006-01-31 20:26 ` reichelt at gcc dot gnu dot org
2006-02-01 11:53 ` reichelt at gcc dot gnu dot org
2006-02-01 11:54 ` reichelt at gcc dot gnu dot org

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