public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23950] New: Two-phase name lookup crash with "using" a static const integer from a base class as template parameter
@ 2005-09-18 15:43 lichtwerk dot x at laposte dot net
2005-09-18 16:46 ` [Bug c++/23950] [3.4 Regression] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: lichtwerk dot x at laposte dot net @ 2005-09-18 15:43 UTC (permalink / raw)
To: gcc-bugs
Accessing members of base classes depending on template parameters from derived
classes has to be done by postponing the name lookup onte the second phase of
the standard c++ two phase name lookup (if I'm right about that). This means,
one has to use dependent types, so you have to use scope resolution, this-> or
a using declaration in order to access the member of the base class.
Example (this works):
template<typename T>
class Base
{
static const int i = 0;
};
template<typename T>
class Derived : public Base<T>
{
// For two phase name lookup.
using Base<T>::i;
int foo() const { return i; }
};
In order not to obfuscate bigger classes I heavily used using declarations as
shown in the example above (instead of writing "return Base<T>::i;"). However
using a static const integral out of a base class using a using declaration as
a template parameter resulted in an internal compiler error:
internal compiler error: in uses_template_parms, at cp/pt.c:4948
To reproduce the error compile this piece of code:
template<int i>
class X
{
};
template<typename T>
class Base
{
static const int i = 0;
};
template<typename T>
class Derived : public Base<T>
{
// For two phase name lookup.
using Base<T>::i;
X<i> member;
};
If I don't use a using declaration but write
X<Base<T>::i> member;
instead of
using Base<T>::i;
X<i> member;
it works, though.
Thanks in advance
I'm using g++ 4.0.0 on Windows using these files
http://www.thisiscool.com/gcc_mingw.htm#gcj40
However, I have exactly the same internal compiler error using MinGW's g++
3.4.2.
--
Summary: Two-phase name lookup crash with "using" a static const
integer from a base class as template parameter
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: lichtwerk dot x at laposte dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23950
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-18 16:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-18 15:43 [Bug c++/23950] New: Two-phase name lookup crash with "using" a static const integer from a base class as template parameter lichtwerk dot x at laposte dot net
2005-09-18 16:46 ` [Bug c++/23950] [3.4 Regression] " pinskia 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).