[Bug c++/78495] [7 regression][new inheriting ctors] variant members lead to uninitialized parameter
nathan at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 19 12:12:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78495
--- Comment #2 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
Created attachment 40543
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40543&action=edit
reduced testcase
The problem is not with unnamed union members, but with inheriting ctors
passing by value. The temporary 'Ptr' object is passed by implicit reference,
but in the inheriting ctor we pass the address of that reference to the Base
ctor. In this case that means we end up initializing Base::val with a pointer
into the stack frame, rather than NULL.
Note the original testcase has a typo ': val(static_cast<canary&&>(val))' --
the ctor parm and the member variable have the same name, so that's doing self
initialization -- not copying the incoming parm. (not that that;s the bug being
exposed).
More information about the Gcc-bugs
mailing list