For the second evaluation, the second time we call
instantiate_template_1, thus for the interesting g(int) overload, here:
spec = retrieve_specialization (gen_tmpl, targ_ptr, 0);
gcc_assert (tmpl == gen_tmpl
|| ((fndecl = retrieve_specialization (tmpl, orig_args, 0))
== spec)
|| fndecl == NULL_TREE);
if (spec != NULL_TREE)
{
if (FNDECL_RECHECK_ACCESS_P (spec) && (complain & tf_error))
recheck_decl_substitution (spec, gen_tmpl, targ_ptr);
return spec;
}
things are completely different, because spec != NULL_TREE and, more
importantly, complain is tf_none, thus recheck_decl_substitution is
not called, we just return immediately.