This is the mail archive of the gcc-help@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]

Issue with using and const overloaded methods in GCC 3.0.3


The following code

struct A
{
   A( ) { }

    const void a( ) const { }  // Line A
          void a( )       { }        // Line B
};

struct B : public A
{
    B( ) : A( ) { }

    using A::a;
};

int main( unsigned int, char** )
{
    B b1;

    b1.a( );

    const B b2;

    b2.a( );
}

produces the error  "Test.c:XX: passing `const B' as `this' argument of
`void A::a()' discards qualifiers",
which seems to suggest that only the non const version of the method A::a is
brought into the B scope
by the using declaration in B. The error disappears when the line A and B
are reversed which seems
to imply that only the first A::a, whichever it is, is being brought into
scope B.

My understanding of the using declaration in B is that it should bring both
A::a methods into the B scope
and that the const resolution should work fine, am I in error in this or is
the compiler?

Note that I have test on GCC 3.0.3 on Linux 7.2 and Solaris 8. This code
compiles fine on Forte 6 update
2 on Solaris.

David Hunter






------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.



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