[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-14 Thread pdimov at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #19 from Peter Dimov  ---
Thanks!

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-12 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #18 from Marek Polacek  ---
Fixed.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-12 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #17 from GCC Commits  ---
The releases/gcc-16 branch has been updated by Marek Polacek
:

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

commit r16-8896-gf4baf6313b75bb43ae265b12211619273e61ce35
Author: Marek Polacek 
Date:   Thu May 7 16:38:34 2026 -0400

c++/reflection: fixes for comparing reflections [PR125208]

This fixes two bugs:

1) crash in cp_tree_equal when comparing reflections with binfos;
cp_tree_equal doesn't handle those.  We're coming from
lookup_template_class -> spec_hasher::equal -> comp_template_args
-> cp_tree_equal.  We should use compare_reflections in cp_tree_equal.

2) the fix for 1) revealed that compare_reflections is buggy when
comparing two aliases: we shouldn't fall back to same_type_p
because given

   using A = int;
   using B = int;

^^A != ^^B should hold.

PR c++/125208

gcc/cp/ChangeLog:

* reflect.cc (compare_reflections): Use == when comparing two
aliases.
* tree.cc (cp_tree_equal) : Use
compare_reflections.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/alias3.C: New test.
* g++.dg/reflect/bases_of5.C: New test.

Reviewed-by: Patrick Palka 
(cherry picked from commit 7199cf12773b1429c19cdd5b69950b2f09470e64)

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-11 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #16 from Marek Polacek  ---
Fixed on trunk, will backport to 16.2 tomorrow.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-11 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #15 from GCC Commits  ---
The trunk branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:7199cf12773b1429c19cdd5b69950b2f09470e64

commit r17-457-g7199cf12773b1429c19cdd5b69950b2f09470e64
Author: Marek Polacek 
Date:   Thu May 7 16:38:34 2026 -0400

c++/reflection: fixes for comparing reflections [PR125208]

This fixes two bugs:

1) crash in cp_tree_equal when comparing reflections with binfos;
cp_tree_equal doesn't handle those.  We're coming from
lookup_template_class -> spec_hasher::equal -> comp_template_args
-> cp_tree_equal.  We should use compare_reflections in cp_tree_equal.

2) the fix for 1) revealed that compare_reflections is buggy when
comparing two aliases: we shouldn't fall back to same_type_p
because given

   using A = int;
   using B = int;

^^A != ^^B should hold.

PR c++/125208

gcc/cp/ChangeLog:

* reflect.cc (compare_reflections): Use == when comparing two
aliases.
* tree.cc (cp_tree_equal) : Use
compare_reflections.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/alias3.C: New test.
* g++.dg/reflect/bases_of5.C: New test.

Reviewed-by: Patrick Palka 

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-11 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #14 from Marek Polacek  ---
(In reply to Peter Dimov from comment #13)
> Further reduced to only std headers: https://godbolt.org/z/q8vW6r3vM

Wonderful, thanks.  I was able to reduce this better.  Patch posted:
.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-11 Thread pdimov at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #13 from Peter Dimov  ---
Further reduced to only std headers: https://godbolt.org/z/q8vW6r3vM

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-11 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #12 from Marek Polacek  ---
Thanks.  I rerun cvise but I'm not really getting much further than before.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-11 Thread pdimov at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #11 from Peter Dimov  ---
Here's a reduced starting point, where I've eliminated everything unneeded for
the ICE: https://godbolt.org/z/bTcbdEG4j

Maybe it will help.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-11 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #10 from Marek Polacek  ---
(In reply to Patrick Palka from comment #9)
> (In reply to Marek Polacek from comment #8)
> > Created attachment 64408 [details]
> > reduced.C
> > 
> > Reduced to ~2000 lines after ~15 hours of cvise.
> > 
> > Doesn't ICE with values lower than --param ggc-min-expand=923 --param
> > ggc-min-heapsize=256.
> Maybe --param=hash-table-verification-limit= could help reduce it
> further (since the ICE is hash table related)

Sadly, doesn't help :(.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-10 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org

--- Comment #9 from Patrick Palka  ---
(In reply to Marek Polacek from comment #8)
> Created attachment 64408 [details]
> reduced.C
> 
> Reduced to ~2000 lines after ~15 hours of cvise.
> 
> Doesn't ICE with values lower than --param ggc-min-expand=923 --param
> ggc-min-heapsize=256.
Maybe --param=hash-table-verification-limit= could help reduce it further
(since the ICE is hash table related)

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-09 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #8 from Marek Polacek  ---
Created attachment 64408
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64408&action=edit
reduced.C

Reduced to ~2000 lines after ~15 hours of cvise.

Doesn't ICE with values lower than --param ggc-min-expand=923 --param
ggc-min-heapsize=256.

0x321d8e8 internal_error(char const*, ...)
/home/mpolacek/src/gcc/gcc/diagnostic-global-context.cc:787
0x322c1f5 fancy_abort(char const*, int, char const*)
/home/mpolacek/src/gcc/gcc/diagnostics/context.cc:1813
0x90a93f cp_tree_equal(tree_node*, tree_node*)
/home/mpolacek/src/gcc/gcc/cp/tree.cc:4562
0x90a745 cp_tree_equal(tree_node*, tree_node*)
/home/mpolacek/src/gcc/gcc/cp/tree.cc:4522
0x7dc6c7 template_args_equal(tree_node*, tree_node*)
/home/mpolacek/src/gcc/gcc/cp/pt.cc:9722
0x7dc7e9 comp_template_args(tree_node*, tree_node*, tree_node**, tree_node**)
/home/mpolacek/src/gcc/gcc/cp/pt.cc:9748
0x7b737a spec_hasher::equal(spec_entry*, spec_entry*)
/home/mpolacek/src/gcc/gcc/cp/pt.cc:1713
0x8636e9 hash_table::find_with_hash(spec_entry* const&, unsigned int)
/home/mpolacek/src/gcc/gcc/hash-table.h:999
0x861e4b hash_table::find(spec_entry* const&)
/home/mpolacek/src/gcc/gcc/hash-table.h:430
0x7dedbe lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
/home/mpolacek/src/gcc/gcc/cp/pt.cc:10436
0x880cd8 eval_can_substitute
/home/mpolacek/src/gcc/gcc/cp/reflect.cc:5503
0x880ea0 eval_substitute
/home/mpolacek/src/gcc/gcc/cp/reflect.cc:5553
0x88fd9a process_metafunction(constexpr_ctx const*, tree_node*, tree_node*,
bool*, bool*, tree_node**)
/home/mpolacek/src/gcc/gcc/cp/reflect.cc:8195
0x49268f cxx_eval_call_expression
/home/mpolacek/src/gcc/gcc/cp/constexpr.cc:4036
0x4aa596 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/mpolacek/src/gcc/gcc/cp/constexpr.cc:9401
0x4ab11e cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/mpolacek/src/gcc/gcc/cp/constexpr.cc:9538
0x4ac588 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/mpolacek/src/gcc/gcc/cp/constexpr.cc:9828
0x4ad272 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/mpolacek/src/gcc/gcc/cp/constexpr.cc:10123
0x48dff0 cxx_bind_parameters_in_call
/home/mpolacek/src/gcc/gcc/cp/constexpr.cc:2935
0x493b1d cxx_eval_call_expression
/home/mpolacek/src/gcc/gcc/cp/constexpr.cc:4256

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

Drea Pinski  changed:

   What|Removed |Added

   Keywords||GC

--- Comment #7 from Drea Pinski  ---
so I tried different GC params and the ICE sometimes goes way with much lower
ones on a reduced testcase.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-08 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

--- Comment #6 from Marek Polacek  ---
I have a patch but the reduction will take some time :/.

02:11:11 INFO (93.9%, 93038 bytes, 2328 lines)

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-07 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #5 from Marek Polacek  ---
Using compare_reflections results in
FAIL: g++.dg/reflect/alias1.C  -std=c++26 (internal compiler error: canonical
types differ for identical types 'A<^^alias>' and 'A<^^alias_t >')
FAIL: g++.dg/reflect/alias1.C  -std=c++26 (test for excess errors)

Poking more...

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-06 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

Marek Polacek  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2026-05-06

--- Comment #4 from Marek Polacek  ---
I can take a look.

[Bug c++/125208] [reflection] Another internal compiler error when using bases_of in cp_tree_equal

2026-05-06 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125208

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||mpolacek at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
Wonder why cp_tree_equal for REFLECT_EXPR doesn't just compare_reflections.
If for some reason it can't, then
case REFLECT_EXPR:
  {
if (REFLECT_EXPR_KIND (t1) != REFLECT_EXPR_KIND (t2))
  return false;
tree h1 = REFLECT_EXPR_HANDLE (t1);
tree h2 = REFLECT_EXPR_HANDLE (t2);
if (!cp_tree_equal (h1, h2))
  return false;
/* ^^alias represents the alias itself, not the underlying type.  */
if (TYPE_P (h1)
&& (typedef_variant_p (h1) || typedef_variant_p (h2))
&& TYPE_NAME (h1) != TYPE_NAME (h2))
  return false;
return true;
  }
then it should be at least doing maybe_get_first_fn, and
maybe_update_function_parm,
and for REFLECT_ANNOTATION TREE_VALUE comparison.