public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15534] New: Fails to inherit types from base class
@ 2004-05-19 19:27 igodard at pacbell dot net
  2004-05-19 19:42 ` [Bug c++/15534] " igodard at pacbell dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-19 19:27 UTC (permalink / raw)
  To: gcc-bugs

In the source at the point of the first error messages:
    typedef
    typename std::allocator<T>::size_type st1;
    typedef
    typename size_type  st;
    typedef
    size_type   st2;
the first typedef works but the second two do not even though the class is derived from std::allocator<T>. In simple cases, e.g.:class A{
public:
    typedef
    int B;
    };

class C : public A {
public:
    B b;
    };

the derived class can inherit the types of the base class, but not here. Sticking in a "typename" doesn't help.

-- 
           Summary: Fails to inherit types from base class
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/15534] Fails to inherit types from base class
  2004-05-19 19:27 [Bug c++/15534] New: Fails to inherit types from base class igodard at pacbell dot net
@ 2004-05-19 19:42 ` igodard at pacbell dot net
  2004-05-19 19:47 ` igodard at pacbell dot net
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-19 19:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-05-19 03:04 -------
Created an attachment (id=6334)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6334&action=view)
Compiler output (-v -save-temps)


-- 


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


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

* [Bug c++/15534] Fails to inherit types from base class
  2004-05-19 19:27 [Bug c++/15534] New: Fails to inherit types from base class igodard at pacbell dot net
  2004-05-19 19:42 ` [Bug c++/15534] " igodard at pacbell dot net
@ 2004-05-19 19:47 ` igodard at pacbell dot net
  2004-05-19 20:22 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-19 19:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-05-19 03:06 -------
Created an attachment (id=6335)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6335&action=view)
Source code (-save-temps)


-- 


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


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

* [Bug c++/15534] Fails to inherit types from base class
  2004-05-19 19:27 [Bug c++/15534] New: Fails to inherit types from base class igodard at pacbell dot net
  2004-05-19 19:42 ` [Bug c++/15534] " igodard at pacbell dot net
  2004-05-19 19:47 ` igodard at pacbell dot net
@ 2004-05-19 20:22 ` pinskia at gcc dot gnu dot org
  2004-05-19 23:47 ` igodard at pacbell dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-19 20:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-19 03:12 -------
This is equivent to:
template <class T> class A
{
  typedef int t;
};

template <class T> class B: A<T>
{
  typedef t t1;
};

Which is invalid as t is not dependent so it needs to be declare not in the subclasses.
The fix would be to declare t1 as "typedef A<T>::t t1;"

Also one the mainline I get the following note:
pr15534.ii:31253: error: `size_type' does not name a type
pr15534.ii:31253: note: (perhaps `typename std::allocator<_CharT>::size_type' was intended)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/15534] Fails to inherit types from base class
  2004-05-19 19:27 [Bug c++/15534] New: Fails to inherit types from base class igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2004-05-19 20:22 ` pinskia at gcc dot gnu dot org
@ 2004-05-19 23:47 ` igodard at pacbell dot net
  2004-05-20  0:59 ` pinskia at gcc dot gnu dot org
  2004-05-20 13:37 ` bangerth at dealii dot org
  5 siblings, 0 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2004-05-19 23:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-05-19 09:30 -------
Comment three says the original example was invalid:
"Which is invalid as t is not dependent so it needs to be declare not in the subclasses". So here is a different example where "t" *is* dependent, and it fails too.

template <class T> class A
{
typedef T* t;
};

template <class T> class B: A<T>
{
typedef t t1;
};

or am I not understanding what you mean by dependent?

g++3.4.0 gives:
foo.cc:8: error: `t' does not name a type
foo.cc:8: error: (perhaps `typename A<T>::t' was intended)

Ivan

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug c++/15534] Fails to inherit types from base class
  2004-05-19 19:27 [Bug c++/15534] New: Fails to inherit types from base class igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2004-05-19 23:47 ` igodard at pacbell dot net
@ 2004-05-20  0:59 ` pinskia at gcc dot gnu dot org
  2004-05-20 13:37 ` bangerth at dealii dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-20  0:59 UTC (permalink / raw)
  To: gcc-bugs

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


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-19 11:16 -------
You misunderstand. 

Type-dependent expressions (From 14.6.2.2 P3):

Anid-expressionis type-dependent if it contains: 
—an identifier that was declared with a dependent type,
—a template-id that is dependent,
—a conversion-function-id that specifies a dependent type,
—a nested-name-specifier that contains a class-name that names a dependent type. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c++/15534] Fails to inherit types from base class
  2004-05-19 19:27 [Bug c++/15534] New: Fails to inherit types from base class igodard at pacbell dot net
                   ` (4 preceding siblings ...)
  2004-05-20  0:59 ` pinskia at gcc dot gnu dot org
@ 2004-05-20 13:37 ` bangerth at dealii dot org
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-05-20 13:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-05-19 13:42 -------
In your example, 
------ 
template <class T> class B: A<T> 
{ 
typedef t t1; 
}; 
------ 
you reference the name 't'. Since 't' does not depend on the template 
argument 'T', it is non-dependent and needs to be looked up at the 
time of declaration of the template. However, since name lookup does 
not look into template dependent base classes such as A<T> it doesn't 
find anything. The solution is to make sure that 't' is qualified as 
dependent, for example by writing 'typename A<T>::t'. 
 
This is really no different than all the other name lookup things that 
we believe are well-documented in the non-bugs and changes-in-3.4 sections 
of our web pages. Please review these if you are unsure. 
 
W. 

-- 


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


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

end of thread, other threads:[~2004-05-19 13:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-19 19:27 [Bug c++/15534] New: Fails to inherit types from base class igodard at pacbell dot net
2004-05-19 19:42 ` [Bug c++/15534] " igodard at pacbell dot net
2004-05-19 19:47 ` igodard at pacbell dot net
2004-05-19 20:22 ` pinskia at gcc dot gnu dot org
2004-05-19 23:47 ` igodard at pacbell dot net
2004-05-20  0:59 ` pinskia at gcc dot gnu dot org
2004-05-20 13:37 ` bangerth at dealii 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).