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

--- Comment #2 from Markus Eisenmann <meisenmann....@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).

Reply via email to