[Bug c++/60201] Issue with CRTP generation under 4.8.1

andrew.stern at itg dot com gcc-bugzilla@gcc.gnu.org
Fri Feb 14 19:30:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60201

--- Comment #2 from Andrew Stern <andrew.stern at itg dot com> ---
>>Is this valid as *this at this point is just a Baseclass type (and does not have a Subclass type.

I believe the code to be valid since the template generates both the Baseclass
and Subclass.  The Subclass object is really just the same object as the
Baseclass and the sizeof operator seems to give the correct values.  Note that
the code compiles and runs and the correct member functions get called.  If you
think this is the issue what is the correct method to get the Subclass type.

Note the line also is consistent with the code located at:
http://eli.thegreenplace.net/2011/05/17/the-curiously-recurring-template-pattern-in-c/

Specifically:    const Derived& d1 = static_cast<const Derived&>(o1);



More information about the Gcc-bugs mailing list