[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
gcc-bugzilla@gcc.gnu.org
Sun Sep 18 15:43:00 GMT 2005
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
More information about the Gcc-bugs
mailing list