[Bug c++/87897] [9 Regression] ICE in maybe_constant_value, at cp/constexpr.c:5255 since r265788

2018-12-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87897

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #6 from Jakub Jelinek  ---
Fixed by r266816 aka PR85569 fix.

*** This bug has been marked as a duplicate of bug 85569 ***

[Bug c++/87897] [9 Regression] ICE in maybe_constant_value, at cp/constexpr.c:5255 since r265788

2018-12-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87897

--- Comment #5 from Jakub Jelinek  ---
Author: jakub
Date: Wed Dec  5 08:43:12 2018
New Revision: 266818

URL: https://gcc.gnu.org/viewcvs?rev=266818=gcc=rev
Log:
PR c++/87897
* g++.dg/init/const13.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/init/const13.C
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug c++/87897] [9 Regression] ICE in maybe_constant_value, at cp/constexpr.c:5255 since r265788

2018-11-30 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87897

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
Slightly cleaned up testcase:
typedef struct A {} B;
A const a = B ();

The problem is that we have a TARGET_EXPR with B type and an empty CONSTRUCTOR
with B type, then cxx_eval_outermost_constant_expr is processing it,
5111  if (TREE_CODE (r) == CONSTRUCTOR && CLASS_TYPE_P (TREE_TYPE (r)))
5112{
5113  r = adjust_temp_type (type, r);
5114  if (TREE_CODE (t) == TARGET_EXPR
5115  && TARGET_EXPR_INITIAL (t) == r)
5116return t;
5117  else if (TREE_CODE (t) != CONSTRUCTOR)
5118{
5119  r = get_target_expr (r);
5120  TREE_CONSTANT (r) = true;
5121}
and then in the caller
5259  r = cxx_eval_outermost_constant_expr (t, true, true, false, decl);
5260  gcc_checking_assert (r == t
5261   || CONVERT_EXPR_P (t)
5262   || TREE_CODE (t) == VIEW_CONVERT_EXPR
5263   || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
5264   || !cp_tree_equal (r, t));

For A const a = A (); adjust_temp_type returns the passed r and thus r == t in
the caller, but for A const a = B (); adjust_temp_type creates a new
CONSTRUCTOR (with A type), also a new TARGET_EXPR because of that, but both are
cp_tree_equal, as it doesn't care about exact type as long as it has
same_type_p.

So, shall adjust_temp_type not bother if it is same_type_p, or shall the assert
be adjusted, or shall we adjust the type earlier already?  The assert is there
already since r166166.

[Bug c++/87897] [9 Regression] ICE in maybe_constant_value, at cp/constexpr.c:5255 since r265788

2018-11-29 Thread proski at gnu dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87897

Pavel Roskin  changed:

   What|Removed |Added

 CC||proski at gnu dot org

--- Comment #3 from Pavel Roskin  ---
Confirmed with the current revision. Compiling a program using Boost.Spirit,
Boost 1.61.

/usr/local/include/boost/spirit/home/support/argument.hpp:202:5: internal
compiler error: in maybe_constant_value, at cp/constexpr.c:5260
  202 | BOOST_PP_REPEAT_FROM_TO(
  | ^~~
0x5c9842 maybe_constant_value(tree_node*, tree_node*)
/home/roskinp/src/gcc/gcc/cp/constexpr.c:5260
0xa03aec store_init_value(tree_node*, tree_node*, vec**, int)
/home/roskinp/src/gcc/gcc/cp/typeck2.c:825
0x897b62 check_initializer
/home/roskinp/src/gcc/gcc/cp/decl.c:6486

[Bug c++/87897] [9 Regression] ICE in maybe_constant_value, at cp/constexpr.c:5255 since r265788

2018-11-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87897

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-11-06
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Marek Polacek  ---
Confirmed.

[Bug c++/87897] [9 Regression] ICE in maybe_constant_value, at cp/constexpr.c:5255 since r265788

2018-11-06 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87897

--- Comment #1 from Martin Liška  ---
One more test-case:

$ cat ice.ii
struct c {
  int b;
};
struct e : c {
  constexpr e() : c{} {}
};
using d = e;
const int ((2, d{}).b);

$ g++ ice.ii -c
ice.ii:8:24: internal compiler error: in build_target_expr_with_type, at
cp/tree.c:793
8 | const int ((2, d{}).b);
  |^
0x67a78d build_target_expr_with_type(tree_node*, tree_node*, int)
../../gcc/cp/tree.c:793
0x887963 cxx_eval_outermost_constant_expr
../../gcc/cp/constexpr.c:5110
0x88accc maybe_constant_init_1
../../gcc/cp/constexpr.c:5371
0x859d10 set_up_extended_ref_temp
../../gcc/cp/call.c:11144
0x859d10 extend_ref_init_temps_1
../../gcc/cp/call.c:11304
0xa217f7 store_init_value(tree_node*, tree_node*, vec**, int)
../../gcc/cp/typeck2.c:815
0x8b334d check_initializer
../../gcc/cp/decl.c:6486
0x8cb79c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
../../gcc/cp/decl.c:7162
0x96776b cp_parser_init_declarator
../../gcc/cp/parser.c:20033
0x96f203 cp_parser_simple_declaration
../../gcc/cp/parser.c:13219
0x974262 cp_parser_declaration
../../gcc/cp/parser.c:12916
0x974a0c cp_parser_translation_unit
../../gcc/cp/parser.c:4668
0x974a0c c_parse_file()
../../gcc/cp/parser.c:39266
0xa77000 c_common_parse_file()
../../gcc/c-family/c-opts.c:1150

[Bug c++/87897] [9 Regression] ICE in maybe_constant_value, at cp/constexpr.c:5255 since r265788

2018-11-06 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87897

Martin Liška  changed:

   What|Removed |Added

  Known to work||8.2.0
   Target Milestone|--- |9.0
  Known to fail||9.0