This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
http://gcc.gnu.org/gcc-3.4/changes.html
- From: "Johan Bergman (KI/EAB)" <johan dot bergman at ericsson dot com>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 18 Sep 2004 03:03:30 +0200
- Subject: http://gcc.gnu.org/gcc-3.4/changes.html
Hi,
Giovanni Bajo asked me (se mail below) to provide a patch of
http://gcc.gnu.org/gcc-3.4/changes.html
I don't really know how to do that but here is the modified part:
<li>In a template definition, unqualified names will no longer
find members of a dependent base. For example,
<pre>
template <typename T> struct B {
int m;
int n;
int f ();
int g ();
};
int n;
int g ();
template <typename T> struct C : B<T> {
void h ()
{
m = 0; // error
f (); // error
n = 0; // ::n is modified
g (); // ::g is called
}
};</pre>
<p>You must make the names dependent, e.g. by prefixing them
with <code>this-></code>. Here is the corrected definition
of <code>C<T>::h</code>,</p>
<pre>
template <typename T> void C<T>::h ()
{
this->m = 0;
this->f ();
this->n = 0
this->g ();
}</pre>
<p>As an alternative solution, you may use <code>using</code>
declarations instead of <code>this-></code>:</p>
<pre>
template <typename T> struct C : B<T> {
using B<T>::m;
using B<T>::f;
using B<T>::n;
using B<T>::g;
void h ()
{
m = 0;
f ();
n = 0;
g ();
}
};</pre></li>
BR,
Johan
-----Original Message-----
From: Giovanni Bajo [mailto:giovannibajo@libero.it]
Sent: den 18 september 2004 01:39
To: Johan Bergman (KI/EAB)
Cc: gcc@gcc.gnu.org
Subject: Re: Error on GCC 3.4 release web page
Johan Bergman (KI/EAB) wrote:
> There seems to be an error in the following example, found on
http://gcc.gnu.org/gcc-3.4/changes.html.
> The problem with the example is that the member function g() in C<T> calls
itself.
Actually the example is meant to show name lookup issue, not to have a proper
runtime behaviour. Anyway, I would not object renaming that function to avoid
any confusion for the user.
> Maybe you could also mention the following alternative corrected
> definition of C<T>::h.
> template <typename T> struct C : B<T> {
> using B<T>::m;
> using B<T>::f;
> using B<T>::n;
> using B<T>::g;
Makes sense. Can you please provide a patch against the HTML file, and post it
to gcc-patches@gcc.gnu.org?
Thanks,
Giovanni Bajo