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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Seems the problem is that we instantiate NSDMIs on demand and only once, and so
the instantiation ends up being inadvertently sensitive to whether the
instantiation was first performed from a template context.

In the comment #1 testcase, with -fchecking=2 we end up instantiating the NSDMI
for bar<1>::alloc_ for the first time from the template context func1<N>, via
fold_non_dependent_expr.  During this instantiation we call mark_used for
foo<2>'s default ctor but in_template_function() is true at this point and
mark_used exits early without scheduling the ctor for instantiation.  We never
call mark_used again for foo<2>'s default ctor since we process/instantiate an
NSDMI once.

I guess we need to somehow make sure in_template_function() always returns
false from maybe_instantiate_nsdmi_init and/or synthesized_method_walk..

Reply via email to