Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 14–6–1 and injected-class-names
#2
For what it's worth, at least one implementation binds the call 'B::j()' to ::N::B::j() in the instantiation of ::A::f2(), but it should bind to ::B::j(). So it seems pretty clear that we need to regard the use of 'B' in f2() as non-compliant.

Also, since submitting the above post, I've found that some popular implementations don't correctly handle the uses of injected-class-names in the class template A above, so MISRA may want to say something about that. For example, MISRA may want to say that the 'safe' way to refer to a base class within a derived class involves a member typedef name; e.g.:

Code:
struct D : public N::B {
    typedef ::N::B B1; //compliant

    typedef N::B B2; // non-compliant
       // ('N' could be found in the base at instantiation time by a buggy compiler.)

    typedef B  B3; // non-compliant

    void f ( ) {
        B1::j(); // compliant
       // (unqualified lookup for 'B1' does not go up against a dependent base)
    }
};
<r>James Widman<br/>
-- <br/>
Gimpel Software<br/>
<URL url="http://gimpel.com">http://gimpel.com</URL></r>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)