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

* [Bug c++/24915] [3.4/4.0/4.1 Regression] Overload errors generated without template instantiations for class member templates
  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 ` pinskia at gcc dot gnu dot org
  2005-11-19  2:19 ` mmitchel at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-17 17:36 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.3


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


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

* [Bug c++/24915] [3.4/4.0/4.1 Regression] Overload errors generated without template instantiations for class member templates
  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
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-11-19  2:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mmitchel at gcc dot gnu dot org  2005-11-19 02:19 -------
Should be fixed before release.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


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


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

* [Bug c++/24915] [3.4/4.0/4.1/4.2 Regression] Overload errors generated without template instantiations for class member templates
  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 ` bangerth at dealii dot org
  2005-12-12 22:39 ` reichelt at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2005-11-23  5:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bangerth at dealii dot org  2005-11-23 05:22 -------
Confirmed.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-11-23 05:22:57
               date|                            |


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


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

* [Bug c++/24915] [3.4/4.0/4.1/4.2 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (2 preceding siblings ...)
  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
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2005-12-12 22:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from reichelt at gcc dot gnu dot org  2005-12-12 22:39 -------
Shorter testcase:

================================
struct A
{
    template<int> void foo() {}
    template<int> int foo() {}
};
================================

This compiles correctly without the struct.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org
           Keywords|                            |monitored
      Known to fail|3.2.3 3.4.0 4.1.0 4.0.2     |3.2 3.2.3 3.4.0 4.1.0 4.0.2
      Known to work|2.95.3 3.0.4                |2.95.3 3.0.4 3.1


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


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

* [Bug c++/24915] [3.4/4.0/4.1/4.2 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (3 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-12-20  2:01 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/24915] [3.4/4.0/4.1/4.2 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (4 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-12-20  4:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mmitchel at gcc dot gnu dot org  2005-12-20 04:36 -------
Subject: Bug 24915

Author: mmitchel
Date: Tue Dec 20 04:36:29 2005
New Revision: 108835

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108835
Log:
        PR c++/24915
        * class.c (add_method): Do not treat templates as identical unless
        their return types are the same.
        PR c++/24915
        * g++.dg/template/overload8.C: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/overload8.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/class.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/24915] [3.4/4.0/4.1/4.2 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (5 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-12-20  4:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mmitchel at gcc dot gnu dot org  2005-12-20 04:39 -------
Subject: Bug 24915

Author: mmitchel
Date: Tue Dec 20 04:39:30 2005
New Revision: 108836

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108836
Log:
        PR c++/24915
        * class.c (add_method): Do not treat templates as identical unless
        their return types are the same.
        PR c++/24915
        * g++.dg/template/overload8.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/overload8.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/class.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/24915] [3.4/4.0/4.1/4.2 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (6 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-12-20  4:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from mmitchel at gcc dot gnu dot org  2005-12-20 04:44 -------
Subject: Bug 24915

Author: mmitchel
Date: Tue Dec 20 04:44:20 2005
New Revision: 108837

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108837
Log:
        PR c++/24915
        * class.c (add_method): Do not treat templates as identical unless
        their return types are the same.
        PR c++/24915
        * g++.dg/template/overload8.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/overload8.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/24915] [3.4 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (7 preceding siblings ...)
  2005-12-20  4:44 ` mmitchel at gcc dot gnu dot org
@ 2005-12-20  4:49 ` mmitchel at gcc dot gnu dot org
  2006-01-31 20:26 ` reichelt at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-12-20  4:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mmitchel at gcc dot gnu dot org  2005-12-20 04:49 -------
Fixed in 4.0.3, 4.1.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|mark at codesourcery dot com|unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW
            Summary|[3.4/4.0/4.1/4.2 Regression]|[3.4 Regression] Overload
                   |Overload errors generated   |errors generated without
                   |without template            |template instantiations for
                   |instantiations for class    |class member templates
                   |member templates            |
   Target Milestone|4.0.3                       |3.4.6


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


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

* [Bug c++/24915] [3.4 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (8 preceding siblings ...)
  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
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-01-31 20:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from reichelt at gcc dot gnu dot org  2006-01-31 20:26 -------
Taking care of the backport.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |reichelt at gcc dot gnu dot
                   |dot org                     |org
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2006-
                   |                            |01/msg02231.html
             Status|NEW                         |ASSIGNED
           Keywords|                            |patch


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


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

* [Bug c++/24915] [3.4 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (9 preceding siblings ...)
  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
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-02-01 11:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from reichelt at gcc dot gnu dot org  2006-02-01 11:52 -------
Subject: Bug 24915

Author: reichelt
Date: Wed Feb  1 11:52:56 2006
New Revision: 110472

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110472
Log:
        Backport:
        2005-12-19  Mark Mitchell  <mark@codesourcery.com>

        PR c++/24915
        * class.c (add_method): Do not treat templates as identical unless
        their return types are the same.

        * g++.dg/template/overload8.C: New test.

Added:
    branches/gcc-3_4-branch/gcc/testsuite/g++.dg/template/overload8.C
Modified:
    branches/gcc-3_4-branch/gcc/cp/ChangeLog
    branches/gcc-3_4-branch/gcc/cp/class.c
    branches/gcc-3_4-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/24915] [3.4 Regression] Overload errors generated without template instantiations for class member templates
  2005-11-17 17:26 [Bug c++/24915] New: Overload errors generated without template instantiations for class member templates nem3 at pitt dot edu
                   ` (10 preceding siblings ...)
  2006-02-01 11:53 ` reichelt at gcc dot gnu dot org
@ 2006-02-01 11:54 ` reichelt at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-02-01 11:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from reichelt at gcc dot gnu dot org  2006-02-01 11:54 -------
Now also fixed on the 3.4 branch.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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