public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21484] New: [g++] using typename doesn't work in case template : template inheritance
@ 2005-05-10 8:26 smelkov at mph1 dot phys dot spbu dot ru
2005-05-10 16:35 ` [Bug c++/21484] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: smelkov at mph1 dot phys dot spbu dot ru @ 2005-05-10 8:26 UTC (permalink / raw)
To: gcc-bugs
Is it just me or what?
===nested_defs.cpp===
template<typename T>
struct A
{
typedef T value_type;
};
template<class T>
struct B : A<T>
{
using typename A<T>::value_type;
value_type x;
};
int main()
{
B<int> b;
b.x = 0;
return 0;
}
===
[kirr@tugrik tmp]$ g++ -g -c -Wall nested_defs.cpp
nested_defs.cpp:12: error: 'value_type' does not name a type
nested_defs.cpp:12: note: (perhaps 'typename A<T>::value_type' was intended)
nested_defs.cpp: In function 'int main()':
nested_defs.cpp:20: error: 'struct B<int>' has no member named 'x'
[kirr@tugrik tmp]$ g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.0/configure --prefix=/usr/local/gcc-4.0.0--nocheck-native
--with-gnu-as --with-gnu-ld --enable-threads=posix --with-arch=pentium3
--with-tune=pentium4 --enable-__cxa_atexit --enable-languages=c,c++,java,f95
--disable-checking --disable-nls
Thread model: posix
gcc version 4.0.0
With Comeau C++ & Intel 8.0 C++ it is ok.
---
By the way, if i want to access all members of A<T> inside B, without explicit using, typedef,
etc, what can i do?
damn, if B is not template it works
===
template<typename T>
struct A
{
typedef T value_type;
};
struct B : A<int>
{
value_type x;
};
===
if A is not template it also works:
===
struct A
{
typedef int value_type;
};
template<typename T>
struct B : A
{
value_type x;
};
===
only for template : template case it doesn't compile (g++, Comeau), although intel C++ 8.0
works ok:
===
template<typename T>
struct A
{
typedef T value_type;
};
template<typename T>
struct B : A<T>
{
value_type x;
};
int main()
{
B<int> b;
b.x = 0;
return 0;
}
===
[kirr@tugrik tmp]$ /opt/intel_cc_80/bin/icc -c nested_defs.cpp
[kirr@tugrik tmp]$ echo $?
0
--
Summary: [g++] using typename doesn't work in case template :
template inheritance
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: smelkov at mph1 dot phys dot spbu dot ru
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21484
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/21484] [g++] using typename doesn't work in case template : template inheritance
2005-05-10 8:26 [Bug c++/21484] New: [g++] using typename doesn't work in case template : template inheritance smelkov at mph1 dot phys dot spbu dot ru
@ 2005-05-10 16:35 ` pinskia at gcc dot gnu dot org
2005-05-10 17:42 ` pinskia at gcc dot gnu dot org
2005-05-11 5:09 ` smelkov at mph1 dot phys dot spbu dot ru
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-10 16:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-10 16:35 -------
Your first example is valid code.
And the second.
And the third.
But the fourth is invalid code and ICC in strict mode also rejects it.
Confirmed, based on the first example, this comes down to using semantics which G++ does not
always get right, there might be already a bug about this somewhere.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Known to fail| |2.95.3 3.0.4 3.2.3 3.3.3
| |3.4.0 4.0.0 4.1.0
Last reconfirmed|0000-00-00 00:00:00 |2005-05-10 16:35:14
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21484
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/21484] [g++] using typename doesn't work in case template : template inheritance
2005-05-10 8:26 [Bug c++/21484] New: [g++] using typename doesn't work in case template : template inheritance smelkov at mph1 dot phys dot spbu dot ru
2005-05-10 16:35 ` [Bug c++/21484] " pinskia at gcc dot gnu dot org
@ 2005-05-10 17:42 ` pinskia at gcc dot gnu dot org
2005-05-11 5:09 ` smelkov at mph1 dot phys dot spbu dot ru
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-10 17:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-10 17:42 -------
And I was right, there was a bug about this already, see PR 14258 which I am going to mark this bug as
a dup of.
*** This bug has been marked as a duplicate of 14258 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21484
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/21484] [g++] using typename doesn't work in case template : template inheritance
2005-05-10 8:26 [Bug c++/21484] New: [g++] using typename doesn't work in case template : template inheritance smelkov at mph1 dot phys dot spbu dot ru
2005-05-10 16:35 ` [Bug c++/21484] " pinskia at gcc dot gnu dot org
2005-05-10 17:42 ` pinskia at gcc dot gnu dot org
@ 2005-05-11 5:09 ` smelkov at mph1 dot phys dot spbu dot ru
2 siblings, 0 replies; 4+ messages in thread
From: smelkov at mph1 dot phys dot spbu dot ru @ 2005-05-11 5:09 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From smelkov at mph1 dot phys dot spbu dot ru 2005-05-11 05:09 -------
Excuse me. The following is unconditionally offtopic, but
is there a way to use whole base namespace, say something like
template<typename T>
struct A { ... }
template<typename T>
struct B : A<T>
{
using A<T>::* ;
or
using A<T>::;
};
/none of these works, but i think the idea is clear/
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21484
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-11 5:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-10 8:26 [Bug c++/21484] New: [g++] using typename doesn't work in case template : template inheritance smelkov at mph1 dot phys dot spbu dot ru
2005-05-10 16:35 ` [Bug c++/21484] " pinskia at gcc dot gnu dot org
2005-05-10 17:42 ` pinskia at gcc dot gnu dot org
2005-05-11 5:09 ` smelkov at mph1 dot phys dot spbu dot ru
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).