[Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation

2022-05-25 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252

Marek Polacek  changed:

   What|Removed |Added

Summary|[9/10/11/12/13 Regression]  |[9/10/11/12 Regression]
   |Internal compiler error |Internal compiler error
   |during template |during template
   |instantiation   |instantiation

--- Comment #12 from Marek Polacek  ---
Fixed on trunk so far.

[Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation

2022-04-26 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252

Marek Polacek  changed:

   What|Removed |Added

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

[Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation

2022-04-26 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252

--- Comment #10 from Marek Polacek  ---
Proof of concept:

--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -3296,6 +3296,14 @@ finish_compound_literal (tree type, tree
compound_literal,
   if (TREE_CODE (compound_literal) == CONSTRUCTOR)
TREE_HAS_CONSTRUCTOR (compound_literal) = false;
   compound_literal = get_target_expr_sfinae (compound_literal, complain);
+  if (parsing_nsdmi ())
+   {
+ tree obj = TARGET_EXPR_SLOT (compound_literal);
+ tree  = TARGET_EXPR_INITIAL (compound_literal);
+ replace_placeholders (compound_literal, obj);
+ if (TREE_CODE (ctor) == CONSTRUCTOR)
+   CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ctor) = false;
+   }
 }
   else
 /* For e.g. int{42} just make sure it's a prvalue.  */

[Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation

2022-04-26 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252

--- Comment #9 from Marek Polacek  ---
When we are cp_parser_late_parsing_nsdmi for "int y = A{x}.y;" we perform
finish_compound_literal on type=A, compound_literal={((struct B *) this)->x}. 
When digesting this initializer, we call get_nsdmi which creates a
PLACEHOLDER_EXPR for A -- we don't have any object to refer to yet.  After
digesting, we have

  {.x=((struct B *) this)->x, .y=(&)->x}

and since we've created a PLACEHOLDER_EXPR inside it, we marked the whole ctor
CONSTRUCTOR_PLACEHOLDER_BOUNDARY.  f_c_l creates a TARGET_EXPR and returns

  TARGET_EXPR x, .y=(&)->x}>

(*)

Then we get to

  B b = {};

and call store_init_value, which digest the {}, which produces

  {.x=NON_LVALUE_EXPR <0>, .y=(TARGET_EXPR )->x, .y=(&)->x}>).y}

The call to replace_placeholders in store_init_value will not do anything:
we've marked the inner { } CONSTRUCTOR_PLACEHOLDER_BOUNDARY, and it's only a
sub-expression, so replace_placeholders does nothing, so the  stays even though now it was the perfect time to replace it because
we have an object for it: 'b'.

Later, in cp_gimplify_init_expr the *expr_p is

  D.2395 = {.x=(&)->x, .y=(&)->x}

where D.2395 is of type A, but we crash because we hit , which has a different type.


Now here's an idea how we could fix this: at the (*) point in
finish_compound_literal we could replace  with
D.2384 because now we have an object!  Then clear
CONSTRUCTOR_PLACEHOLDER_BOUNDARY, because we no longer have a PLACEHOLDER_EXPR
in the {}.  Then store_init_value will be able to replace  with 'b', and we should be good to go.

[Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation

2022-04-25 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252

--- Comment #8 from Marek Polacek  ---
This is tricky, because we end up with

{.x=(&)->x, .y=(&)->x}

that is, two PLACEHOLDER_EXPRs for different types on the same level in one {
}, so our CONSTRUCTOR_PLACEHOLDER_BOUNDARY mechanism to avoid replacing
unrelated PLACEHOLDER_EXPRs will not work.

[Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation

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

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|9.4 |9.5

--- Comment #7 from Richard Biener  ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

[Bug c++/100252] [9/10/11/12 Regression] Internal compiler error during template instantiation

2021-05-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|8.5 |9.4

--- Comment #6 from Jakub Jelinek  ---
GCC 8 branch is being closed.