public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter
@ 2011-03-02 16:06 boostcpp at gmail dot com
  2011-03-02 16:13 ` [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: boostcpp at gmail dot com @ 2011-03-02 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Type mismatch when a class derived a same name with
                    template parameter
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: boostcpp@gmail.com


This bug report is for gcc 4.6(built in 2011/02/26)
I tried other version(gcc 4.1). But it doesn't have this problem.

struct Base
{
    typedef int T ;
} ;

template < typename T >
struct Derived : Base
{
    T member ; // T is Base::T, its type is int.
    void f()
    {// for instantiation Derived< double >
        // type of T is double
        std::cout << "T= " << typeid(T).name() << std::endl ;
        T variable ;
        // type of variable is double
        std::cout << "variable= " << typeid(variable).name() << std::endl ;
        // type of member is int
        std::cout << "member= " << typeid(member).name() << std::endl; 
    }
};


int main()
{
    Derived< double > d ;
    d.f() ;
}

Derived's base class is non-dependent name, so in the class scope Derived, name
T is Base::T, not a template parameter name T.

So for instantiation Derived<double>, the name T in Derived class scope is
Base::T. it's type is int.

But in gcc 4.6,
Although the type of Derived::member is int,
the type of T become double in the member function body.

It looks like gcc 4.6 treat name T as a template parameter T in member function
body.


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

* [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
@ 2011-03-02 16:13 ` rguenth at gcc dot gnu.org
  2011-03-02 18:21 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-02 16:13 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.2.4
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2011.03.02 16:13:35
     Ever Confirmed|0                           |1
            Summary|Type mismatch when a class  |[4.3/4.4/4.5/4.6
                   |derived a same name with    |Regression] Type mismatch
                   |template parameter          |when a class derived a same
                   |                            |name with template
                   |                            |parameter
   Target Milestone|---                         |4.3.6
      Known to fail|                            |4.3.5, 4.5.2, 4.6.0

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-02 16:13:35 UTC ---
Confirmed.


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

* [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
  2011-03-02 16:13 ` [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu.org
@ 2011-03-02 18:21 ` jakub at gcc dot gnu.org
  2011-03-03 11:20 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-02 18:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dodji at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-02 18:21:07 UTC ---
This changed behavior in
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143315
(i.e. for PR36019 ).


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

* [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
  2011-03-02 16:13 ` [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu.org
  2011-03-02 18:21 ` jakub at gcc dot gnu.org
@ 2011-03-03 11:20 ` jakub at gcc dot gnu.org
  2011-03-03 23:43 ` jason at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-03 11:20 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (2 preceding siblings ...)
  2011-03-03 11:20 ` jakub at gcc dot gnu.org
@ 2011-03-03 23:43 ` jason at gcc dot gnu.org
  2011-03-04 16:01 ` dodji at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-03 23:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-03 23:43:11 UTC ---
Dodji, can you take a look at this one?


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

* [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (3 preceding siblings ...)
  2011-03-03 23:43 ` jason at gcc dot gnu.org
@ 2011-03-04 16:01 ` dodji at gcc dot gnu.org
  2011-03-07 16:26 ` dodji at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-03-04 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-03-04 16:01:03 UTC ---
Sure.


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

* [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (4 preceding siblings ...)
  2011-03-04 16:01 ` dodji at gcc dot gnu.org
@ 2011-03-07 16:26 ` dodji at gcc dot gnu.org
  2011-03-08 15:38 ` dodji at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-03-07 16:26 UTC (permalink / raw)
  To: gcc-bugs

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

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |dodji at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-03-07 16:26:23 UTC ---
Here is a testcase that does away with #include <iostream> and
#include <typeid> requirements:

struct S
{
  int m;

  S()
    : m(0)
  {
  }
};

struct Base
{
  typedef S T;
};

template<class T>
struct Derived : public Base
{
  int
  foo()
  {
    T a; // This is Base::T, not the template parameter.
    return a.m;
  }
};

int
main()
{
  Derived<char> d;
  return d.foo();
}


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

* [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (5 preceding siblings ...)
  2011-03-07 16:26 ` dodji at gcc dot gnu.org
@ 2011-03-08 15:38 ` dodji at gcc dot gnu.org
  2011-03-08 15:41 ` [Bug c++/47957] [4.3/4.4/4.5 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-03-08 15:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-03-08 15:38:35 UTC ---
Author: dodji
Date: Tue Mar  8 15:38:30 2011
New Revision: 170779

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170779
Log:
PR c++/47957

gcc/cp/

    * name-lookup.c (binding_to_template_parms_of_scope_p): Only
    consider scopes of primary template definitions.  Adjust comments.

gcc/testsuite/

    * g++.dg/lookup/template3.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/lookup/template3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/47957] [4.3/4.4/4.5 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (6 preceding siblings ...)
  2011-03-08 15:38 ` dodji at gcc dot gnu.org
@ 2011-03-08 15:41 ` jakub at gcc dot gnu.org
  2011-03-08 21:14 ` dodji at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-08 15:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.6.0
            Summary|[4.3/4.4/4.5/4.6            |[4.3/4.4/4.5 Regression]
                   |Regression] Type mismatch   |Type mismatch when a class
                   |when a class derived a same |derived a same name with
                   |name with template          |template parameter
                   |parameter                   |
      Known to fail|4.6.0                       |

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-08 15:41:51 UTC ---
Fixed on the trunk so far.


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

* [Bug c++/47957] [4.3/4.4/4.5 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (7 preceding siblings ...)
  2011-03-08 15:41 ` [Bug c++/47957] [4.3/4.4/4.5 " jakub at gcc dot gnu.org
@ 2011-03-08 21:14 ` dodji at gcc dot gnu.org
  2011-03-08 22:20 ` dodji at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-03-08 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-03-08 21:14:21 UTC ---
Author: dodji
Date: Tue Mar  8 21:14:18 2011
New Revision: 170790

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170790
Log:
PR c++/47957

gcc/cp/

    * name-lookup.c (binding_to_template_parms_of_scope_p): Only
    consider scopes of primary template definitions.  Adjust comments.

gcc/testsuite/

    * g++.dg/lookup/template3.C: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/lookup/template3.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/name-lookup.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/47957] [4.3/4.4/4.5 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (8 preceding siblings ...)
  2011-03-08 21:14 ` dodji at gcc dot gnu.org
@ 2011-03-08 22:20 ` dodji at gcc dot gnu.org
  2011-03-08 22:30 ` [Bug c++/47957] [4.3 " dodji at gcc dot gnu.org
  2011-06-27 12:15 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-03-08 22:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-03-08 22:20:14 UTC ---
Author: dodji
Date: Tue Mar  8 22:20:11 2011
New Revision: 170793

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170793
Log:
PR c++/47957

gcc/cp/

    * name-lookup.c (binding_to_template_parms_of_scope_p): Only
    consider scopes of primary template definitions.  Adjust comments.

gcc/testsuite/

    * g++.dg/lookup/template3.C: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/template3.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/name-lookup.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/47957] [4.3 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (9 preceding siblings ...)
  2011-03-08 22:20 ` dodji at gcc dot gnu.org
@ 2011-03-08 22:30 ` dodji at gcc dot gnu.org
  2011-06-27 12:15 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-03-08 22:30 UTC (permalink / raw)
  To: gcc-bugs

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

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.3/4.4/4.5 Regression]    |[4.3 Regression] Type
                   |Type mismatch when a class  |mismatch when a class
                   |derived a same name with    |derived a same name with
                   |template parameter          |template parameter

--- Comment #10 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-03-08 22:30:21 UTC ---
Fixed in 4.4, 4.5, and 4.6.


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

* [Bug c++/47957] [4.3 Regression] Type mismatch when a class derived a same name with template parameter
  2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
                   ` (10 preceding siblings ...)
  2011-03-08 22:30 ` [Bug c++/47957] [4.3 " dodji at gcc dot gnu.org
@ 2011-06-27 12:15 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-27 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.3.6                       |4.4.6

--- Comment #11 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-27 12:02:40 UTC ---
Fixed for 4.4.6.


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

end of thread, other threads:[~2011-06-27 12:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02 16:06 [Bug c++/47957] New: Type mismatch when a class derived a same name with template parameter boostcpp at gmail dot com
2011-03-02 16:13 ` [Bug c++/47957] [4.3/4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu.org
2011-03-02 18:21 ` jakub at gcc dot gnu.org
2011-03-03 11:20 ` jakub at gcc dot gnu.org
2011-03-03 23:43 ` jason at gcc dot gnu.org
2011-03-04 16:01 ` dodji at gcc dot gnu.org
2011-03-07 16:26 ` dodji at gcc dot gnu.org
2011-03-08 15:38 ` dodji at gcc dot gnu.org
2011-03-08 15:41 ` [Bug c++/47957] [4.3/4.4/4.5 " jakub at gcc dot gnu.org
2011-03-08 21:14 ` dodji at gcc dot gnu.org
2011-03-08 22:20 ` dodji at gcc dot gnu.org
2011-03-08 22:30 ` [Bug c++/47957] [4.3 " dodji at gcc dot gnu.org
2011-06-27 12:15 ` rguenth at gcc dot gnu.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).