[PR c++/84497] ref to undefined tls init

Jason Merrill jason@redhat.com
Fri Mar 2 18:43:00 GMT 2018


On Fri, Mar 2, 2018 at 11:07 AM, Nathan Sidwell <nathan@acm.org> wrote:
> Jason, Jakub,
> I've simplified the testcase Padraig provided and attached it to
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84497
>
> Notice that 'Base::Base ()' is not a constexpr ctor, because the integer
> member is not initialized.  That means 10.1.4/4.5 is unsatisfied.  So struct
> Base gets its 'has_constexpr' flag set via the Base::Base (int) ctor.
> struct Derived is not so lucky, and 'has_constexpr' is unset.
>
> Thus we end up with an unsatisfied strong reference to _ZTH11derived_obj
>
> NEEDS_CONSTRUCTING && !HAS_CONSTEXPR_CTOR is insufficient to determine
> whether there must be an init fn.
>
> While the patch does indeed work, it may be too pessimal, making the
> reference weak in more cases than necessary.
>
> NEEDS_CONSTRUCTING && !HAS_CONSTEXPR_CTOR && !HAS_DEFAULT_CONSTRUCTOR seems
> like it would be sufficient. and indeed that works in this case.

Do you mean !HAS_TRIVIAL_DFLT rather than !HAS_DEFAULT_CONSTRUCTOR?
That makes sense to me.

Jason



More information about the Gcc-patches mailing list