typedefs, qualified identifiers, class names and name lookup

Discussion in 'C++' started by Ivan A. Kosarev, Jan 13, 2006.

  1. Hello,

    There are three similar programs below. All of these use typedef names,
    qualified identifiers, class names and name lookup mechanism in various
    contexts. I found that most respect C++ compilers differ significantly in
    interpreting the code. So, could anyone pick a correct behavior a conformant
    compiler should follow for each of the cases?

    Please note that I used the following compilers and command-line options:

    EDG 3.6 --strict
    MSVC 13.10.3077 /Za
    GCC 3.4.4 --ansi

    Thank you.

    // 1
    class C {
    public:
    int f();
    };

    int main() {
    typedef C T;
    C c;

    // EDG MSVC GCC
    c.~T(); // ok ok ok
    c.T::~T(); // ok ok ok
    c.T::C::f(); // ok fails ok
    c.T::T::f(); // fails fails fails
    }

    // 2
    class C {
    public:
    typedef int T;
    int f();
    };

    int main() {
    typedef C T;
    C c;

    // EDG MSVC GCC
    c.~T(); // ok ok fails
    c.T::~T(); // ok fails fails
    c.T::C::f(); // ok fails fails
    c.T::T::f(); // fails fails fails
    }


    // 3
    class T {
    public:
    int f();
    };

    class C : public T {
    public:
    typedef int T;
    };

    int main() {
    typedef C T;
    C c;

    // EDG MSVC GCC
    c.~T(); // ok ok fails
    c.T::~T(); // fails ok fails
    c.T::C::f(); // fails fails fails
    c.T::T::f(); // fails fails fails
    }


    --
    Unicals Group -- Development Tools for OEMs
    http://www.unicals.com
     
    Ivan A. Kosarev, Jan 13, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne Shu
    Replies:
    4
    Views:
    766
  2. Replies:
    1
    Views:
    355
    Roedy Green
    Apr 22, 2008
  3. Szabolcs Borsanyi

    Pointer to qualified poitner to qualified object

    Szabolcs Borsanyi, May 30, 2008, in forum: C Programming
    Replies:
    13
    Views:
    564
    Keith Thompson
    Jun 8, 2008
  4. Alf P. Steinbach /Usenet
    Replies:
    0
    Views:
    215
    Alf P. Steinbach /Usenet
    Jul 10, 2010
  5. Replies:
    3
    Views:
    413
    Ivan Sorokin
    Sep 18, 2012
Loading...

Share This Page