Re: Reference to pointer and cast - is this a bug ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Philippe,

> If this is a bug, I did not find it in the bug database.
> If not, can anybody tell me why ?

Not a bug.

A child is a parent.

A child pointer, itself, is a type.
A parent pointer, itself, is a type.

A child pointer is not a parent pointer.

Put ten more trace(c_ptr_r); in your source.  Notice that each one has a
different address.  Anonymous variables are being created - anonymous
variables that have a different type.

Take out the const part of the const& to trace, and you'll notice that the
compiler indicates that is an error - because a child pointer is not a
parent pointer.

Since you used a const&, the child pointer will be treated as if it is a
parent pointer (via the magic of the anonymous variable introduced and
implicit conversion).

The trace statement is printing the address of the anonymous variable, which
is why it differs.

May have something to do with the scaffolding for the SSA optimization, even
in non-optimized code (-O0).

HTH,
--Eljay



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux