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

[Bug middle-end/64642] Malformed code as result of C-cast to (polymorphic) object-reference (depends on opt-level ...)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64642

--- Comment #2 from Markus Eisenmann <meisenmann.lba@fh-salzburg.ac.at> ---
I do not (completely) agree, that the code/result is undefined. Of course, this
sample doesnât make any sense and shouldnât never occur (in a similar form).

But - in this case - the C-style cast, like
    A& ref = (A&) arg;
is a âinterpretedâ as *):
    A& ref = *reinterpret_cast<A*>(&arg);

*) As (IMHO) described in C++ Standard (2003).

Assuming, that arg is passed on stack (Ie. Memory), the code seems to be valid.
If the passed value (itself) points to valid code (and based on the
vtable-layout) itâs may be a valid (sub-) call.

At least, Iâve wondered about the optimizer-result; regardless, whether it
makes sense and compared/based to my understanding of the C++ Standard (or
earlier GCC-releases or other C++-compilers).

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