Development

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Google SoC Project proposal: Wcoercion option

    0 answers - 2120 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    06/05/06, Mike Stump <mrs (AT) apple (DOT) comwrote:
    May 4, 2006, at 4:44 PM, lopezibanez (AT) gmail (DOT) com wrote:
    >struct C : A, B { /* */ };
    >

    I am sorry to say that I don't understand the definition of struct C.
    C is derived from A and B. valid of course in C
    K. This is multiple inheritance. I must admit I have never used this
    feature with structs. Also, my plan was to start with C and from
    simple types to more complex ones. Nevertheless, this may be an
    opportunity to refresh my C++ and also to learn about the internals of
    g++ and how to properly define Wcoercion in the context of classes and
    inheritance.
    I created the following test program from your example:
    #include <iostream>
    using namespace std;
    struct A { int i; };
    struct B { double i; };
    struct C : A,B { long double i; };
    void fB(struct B* b);
    void fB(struct B* b)
    {
    cout << sizeof(b) << ", " << b << endl;
    return;
    }
    void fC(struct C* c);
    void fC(struct C* c)
    {
    cout << sizeof(c) << ", " << c << endl;
    return;
    }
    int main(void)
    {
    struct C c;
    cout << sizeof(&c) << ", " << &c << endl;
    fB(&c);
    fC(&c);
    return 0;
    }
    The output is:
    4, 0xbfe8c4f0
    4, 0xbfe8c4f4
    4, 0xbfe8c4f0
    and thus, in the case of fB() there is a coercion that changes a value
    that doesn't happen for fC(). However, you can never use b as (C *).
    That would produce a compilation error.
    Honestly, I see that there is a change of value, however, I don't see
    what problems may arise from such change (apart from the situation
    where you compare the values of the pointers). Until new arguments are
    provided, my provisional decision would be to include this testcase as
    one that should not generate a warning.
    Gabriel, do you mind if I include your email address in the
    description of the testcase for future reference?
    Cheers,
    Manu.

Re: Google SoC Project proposal: Wcoercion option


max 4000 letters.
Your nickname that display:
In order to stop the spam: 0 + 9 =
QUESTION ON "Development"

EMSDN.COM