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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
template <class T>
struct S
{
  static T max ();
};

template <class A = double>
struct V
{
  double a = S<double>::max[0] ();
};

template <class T>
V<>
foo ()
{
  return {};
}

int
main ()
{
  V<> b = foo<double> ();
}

What happens is that synthesized_method_walk with diag = false calls get_nsdmi
with tf_none, and much deeper there is pointer_int_sum which has:
      if (complain && warn_pointer_arith)
        pedwarn (loc, OPT_Wpointer_arith,
                 "pointer to a function used in arithmetic");
      else if (!complain)
        return error_mark_node;
So, if get_nsdmi were called with tf_warning_or_error, we'd pedwarn on it, but
we are quite and just return error_mark_node from get_nsdmi in that case.
So, we end up with raises = error_mark_node and enter:
          /* Can happen, e.g., in C++98 mode for an ill-formed non-static data
             member initializer (c++/89914).  Also, in C++98, we might have
             failed to deduce RAISES, so try again but complain this time.  */
          if (cxx_dialect < cxx11)
            synthesized_method_walk (type, kind, const_p, &raises, nullptr,
                                     nullptr, nullptr, /*diag=*/true,
                                     &inherited_ctor, inherited_parms);
          /* We should have seen an error at this point.  */
          gcc_assert (seen_error ());
and ICE, because at this point whether we pedwarn or not depends on
-Wpointer-arith, and even if not, pedwarn can warn rather than error etc.

Not really sure what to do here, if it is intentional that with tf_none we are
stricter and fail even on things we could just warn or pedwarn without
-pedantic-errors.

Reply via email to