This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/64642] Malformed code as result of C-cast to (polymorphic) object-reference (depends on opt-level ...)
- From: "meisenmann dot lba at fh-salzburg dot ac dot at" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 19 Jan 2015 19:17:15 +0000
- Subject: [Bug middle-end/64642] Malformed code as result of C-cast to (polymorphic) object-reference (depends on opt-level ...)
- Auto-submitted: auto-generated
- References: <bug-64642-4 at http dot gcc dot gnu dot org/bugzilla/>
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).