[Bug c++/94751] [9/10/11 Regression] ICE on invalid code in maybe_instantiate_noexcept

2021-03-25 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94751

Marek Polacek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Marek Polacek  ---
Fixed in GCC 11.

[Bug c++/94751] [9/10/11 Regression] ICE on invalid code in maybe_instantiate_noexcept

2021-03-25 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94751

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:d4e0bdbc036644401f9de49f594b2bb16b287381

commit r11-7835-gd4e0bdbc036644401f9de49f594b2bb16b287381
Author: Marek Polacek 
Date:   Fri Mar 5 15:46:50 2021 -0500

c++: ICE on invalid with inheriting constructors [PR94751]

This is an ICE on invalid where we crash because since r269032 we
keep error_mark_node around instead of using noexcept_false_spec
when things go wrong; see the walk_field_subobs hunk.

We crash in deduce_inheriting_ctor which calls synthesized_method_walk
to deduce the exception-specification, but fails to do so in this case,
because the testcase is invalid so get_nsdmi returns error_mark_node for
the member 'c', and per r269032 the error_mark_node propagates back to
deduce_inheriting_ctor which subsequently calls build_exception_variant
whereon we crash.  I think we should return early if the deduction fails
and I decided to call mark_used to get an error right away instead of
hoping that it would get called later.  My worry is that we could forget
that there was an error and think that we just deduced noexcept(false).

And then I noticed that the test still crashes in C++98.  Here again we
failed to deduce the exception-specification in implicitly_declare_fn,
but nothing reported an error between synthesized_method_walk and the
assert.  Well, not much we can do except calling synthesized_method_walk
again, this time in the verbose mode and making sure that we did get an
error.

gcc/cp/ChangeLog:

PR c++/94751
* call.c (build_over_call): Maybe call mark_used in case
deduce_inheriting_ctor fails and return error_mark_node.
* cp-tree.h (deduce_inheriting_ctor): Adjust declaration.
* method.c (deduce_inheriting_ctor): Return bool if the deduction
fails.
(implicitly_declare_fn): If raises is error_mark_node, call
synthesized_method_walk with diag being true.

gcc/testsuite/ChangeLog:

PR c++/94751
* g++.dg/cpp0x/inh-ctor37.C: New test.

[Bug c++/94751] [9/10/11 Regression] ICE on invalid code in maybe_instantiate_noexcept

2021-03-11 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94751

--- Comment #6 from Marek Polacek  ---
Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566369.html

Also note https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98352#c2

[Bug c++/94751] [9/10/11 Regression] ICE on invalid code in maybe_instantiate_noexcept

2021-01-19 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94751

--- Comment #5 from Marek Polacek  ---
Actually Comment 3 test is unrelated to the original issue here.  Comment 3
will be fixed by my PR98659 fix, but not the original issue.

[Bug c++/94751] [9/10/11 Regression] ICE on invalid code in maybe_instantiate_noexcept

2021-01-19 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94751

--- Comment #4 from Marek Polacek  ---
I posted a patch for this which fixes this test too.

[Bug c++/94751] [9/10/11 Regression] ICE on invalid code in maybe_instantiate_noexcept

2021-01-19 Thread dcb314 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94751

David Binderman  changed:

   What|Removed |Added

 CC||dcb314 at hotmail dot com

--- Comment #3 from David Binderman  ---

Reduced code is:

template  struct c { static constexpr int d = a; };
template  struct e;
template  struct e { typedef f g; };
template  f aa();
class h {
public:
  template  void ab(i *, j...) { i(j()...); }
};
template  using k = h;
template  class l : public k {};
template  struct m;
template  struct m> {
  using n = l;
  using o = f *;
  template  using p = l;
  template  static void ab(n ac, i q, j...) {
ac.ab(q, j()...);
  }
};
template  struct r;
struct s : m>> {
  struct ad {
typedef p> ae;
  };
};
template  struct af;
template  using ag = typename af::g;
template  class ah {};
template  struct af> { typedef ai g;
};
template  ag> ak(ah);
class al {
public:
  template  void operator=(w);
};
struct am {
  struct an {
s::o ao;
  };
  struct : s::ad::ae, an {
  } ap;
};
template  class x : am {
public:
  template  s aq(j &&...);
};
template 
template 
s x::aq(j &&...) {
  s::ab(ap, ap.ao, aa()...);
}
template  class as;
template  struct r {
  int au;
  r(at...);
  template  void aw(av);
};
class y {
public:
  static constexpr struct {
template  typename e::d, ax>::g ay();
template  static typename e::d, ax>::g ay();
  } az{};
};
template  struct z {
  static void bb() {
ah b;
ak(b) = y::az.ay;
  }
};
template  void be(bc, bd) { z<0>::bb; }
template  r::r(at...) { aw(y::az); }
template  template  void r::aw(av ac) {
  be(au, ac);
}
template  class as {
public:
  as ();
  x bg;
};
template  as ::bf() {
  ax t;
  bg.aq(t);
}
template  as bh(at...);
auto bi = bh(1.0f).bf();

[Bug c++/94751] [9/10/11 Regression] ICE on invalid code in maybe_instantiate_noexcept

2021-01-14 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94751

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2