This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9558: subclass cannot find parent members without explicit"this->" in some cases
- From: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 4 Feb 2003 00:56:01 -0000
- Subject: Re: c++/9558: subclass cannot find parent members without explicit"this->" in some cases
- Reply-to: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
The following reply was made to PR c++/9558; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: "Ryan C. Gordon" <ryan@epicgames.com>
Cc: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9558: subclass cannot find parent members without explicit
"this->" in some cases
Date: Mon, 3 Feb 2003 18:48:50 -0600 (CST)
> Surely there's got to be some consideration for backwards compatibility,
> if not real world issues?
Just to prove my point about surprising behavior:
-----------------------------------------------
#include <iostream>
// ---------
const int N = 2;
// ---------
template <typename T> struct A { // templated base class
static const int N = 1;
};
template <typename T> struct B : A<T> {
B () { std::cout << "N=" << N << std::endl; }
};
// ---------
struct C { // non-templated base class
static const int N = 1;
};
template <typename T> struct D : C {
D () { std::cout << "N=" << N << std::endl; }
};
// ---------
int main () {
B<int> b;
D<int> d;
}
---------------------------------------------
In each case, the question is: which N to take, the one from the base
class, or the global one. Here are a couple of data points:
gcc2.96:
N=2
N=1
present gcc CVS:
N=2
N=1
Intel icc7:
N=1
N=1
Intel icc7 with -Xc -ansi:
N=2
N=1
Compaq cxx:
N=1
N=1
So, what is right and what is wrong? And what is the "real world" you
quote?
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth/