[Bug c++/90172] [9 Regression] ICE: Segmentation fault (in contains_struct_check)

2019-04-23 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90172

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org

[Bug c++/90172] [9 Regression] ICE: Segmentation fault (in contains_struct_check)

2019-04-23 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90172

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
So, I guess the rejects-valid part is a P2 8/9 regression (if the testcase is
really valid) and the ICE is error recovery regression for that (9 only).
For the latter, I guess something like:
--- gcc/cp/pt.c.jj  2019-04-22 16:03:23.0 +0200
+++ gcc/cp/pt.c 2019-04-23 17:21:01.898950417 +0200
@@ -18869,7 +18869,8 @@ tsubst_copy_and_build (tree t,
/* We aren't going to do normal overload resolution, so force the
   template-id to resolve.  */
function = resolve_nondeduced_context (function, complain);
-   for (unsigned i = 0; i < nargs; ++i)
+   unsigned int n_call_args = call_args->length ();
+   for (unsigned i = 0; i < n_call_args; ++i)
  {
/* In a thunk, pass through args directly, without any
   conversions.  */
@@ -18881,9 +18882,10 @@ tsubst_copy_and_build (tree t,
if (thisarg)
  {
/* Shift the other args over to make room.  */
-   vec_safe_push (call_args, (*call_args)[nargs-1]);
-   for (int i = nargs-1; i > 0; --i)
- (*call_args)[i] = (*call_args)[i-1];
+   tree last_arg = (*call_args)[n_call_args - 1];
+   vec_safe_push (call_args, last_arg);
+   for (int i = n_call_args - 1; i > 0; --i)
+ (*call_args)[i] = (*call_args)[i - 1];
(*call_args)[0] = thisarg;
  }
ret = build_call_a (function, call_args->length (),

could do the job, nargs doesn't take into account if there are more arguments
in call_args due to some pack expansion and also the vec_safe_push is broken
because (*call_args)[nargs-1] is just a reference and trying to push it if it
needs to reallocate is broken.
I have no idea if n_call_args could be 0 and thisarg non-NULL, if yes, we need
to just vec_safe_push (call_args, thisarg); in that case instead of moving
anything.

[Bug c++/90172] [9 Regression] ICE: Segmentation fault (in contains_struct_check)

2019-04-23 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90172

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
This used to be accepted before r251433, which started rejecting it.
Before r257018, the diagnostics has been:
pr90172.C: In instantiation of ‘fooV(Ts ...) [with Ts = {const char*, int,
double, char, float, short int, unsigned int}]:: [with
auto:1 = {fooV(Ts ...) [with Ts = {const char*, int, double, char, float, short
int, unsigned int}]::, const char*, int, double, char,
float, short int, unsigned int}]’:
pr90172.C:8:13:   required from ‘int fooV(Ts ...) [with Ts = {const char*, int,
double, char, float, short int, unsigned int}]’
pr90172.C:13:65:   required from here
pr90172.C:3:10: error: use ‘...’ to expand argument pack
 auto M = [](decltype(a) ... b) -> void {
  ^
pr90172.C:5:12: error: unable to deduce lambda return type from ‘M’
 return M;
^
but in r257018 and onwards:
pr90172.C: In instantiation of ‘int fooV(Ts ...) [with Ts = {const char*, int,
double, char, float, short int, unsigned int}]’:
pr90172.C:13:65:   required from here
pr90172.C:3:10: error: expansion pattern ‘decltype (#‘nontype_argument_pack’
not supported by dump_expr#)’ contains no argument packs
 auto M = [](decltype(a) ... b) -> void {
  ^
and finally starting with r268377 we also ICE during error recovery.

[Bug c++/90172] [9 Regression] ICE: Segmentation fault (in contains_struct_check)

2019-04-23 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90172

Richard Biener  changed:

   What|Removed |Added

   Keywords|error-recovery  |ice-on-valid-code
   Target Milestone|--- |9.0

--- Comment #2 from Richard Biener  ---
If previous compilers didn't ICE but still reject the testcase this PR would be
P4, if we correctly accepted the code before it would be P1.

[Bug c++/90172] [9 Regression] ICE: Segmentation fault (in contains_struct_check)

2019-04-21 Thread paolo.carlini at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90172

Paolo Carlini  changed:

   What|Removed |Added

   Keywords||rejects-valid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-04-21
 CC||paolo.carlini at oracle dot com
 Ever confirmed|0   |1

--- Comment #1 from Paolo Carlini  ---
I think this is also a rejects-valid.