Structs with pointers?

bearophile bearophileHUGS at lycos.com
Sat Jan 22 14:56:08 PST 2011


Sean Eskapp:

> Nevermind, I realized it's because constness is transitive in pointers. A const
> struct with a pointer member has a const pointer member, and those can't be
> implicitly cast to non-const pointer members.

Uhm, the struct having a pointer is not important. In theory this too can't compile:

struct Bar {}

void foo(Bar b) {}

void main() {
    const b = Bar();
    foo(b);
}

Is this another compiler bug?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list