This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/9558: subclass cannot find parent members without explicit"this->" in some cases


> 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/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]