public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "lichtwerk dot x at laposte dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/23950] New: Two-phase name lookup crash with "using" a static const integer from a base class as template parameter
Date: Sun, 18 Sep 2005 15:43:00 -0000	[thread overview]
Message-ID: <20050918154321.23950.lichtwerk.x@laposte.net> (raw)

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


             reply	other threads:[~2005-09-18 15:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-18 15:43 lichtwerk dot x at laposte dot net [this message]
2005-09-18 16:46 ` [Bug c++/23950] [3.4 Regression] " pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050918154321.23950.lichtwerk.x@laposte.net \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).