On Thu, Nov 12, 2026 at 09:40:59AM +0100, Jakub Jelinek wrote:
> 2) added module.cc handling of _BitInt, enough to handle some cases, but
> when testing with the libstdc++ part of changes I'm still seeing
> internal compiler error: unexpected expression '_Np' of kind
> template_parm_index
> on a couple of testcases (where _Np is template parameter used in
> _BitInt(_Np)), so some further work will be needed for that.
The ICE is e.g.
FAIL: g++.dg/modules/string-1_b.C -std=c++17 (internal compiler error:
unexpected expression '_Np' of kind template_parm_index)
FAIL: g++.dg/modules/string-1_b.C -std=c++17 (test for excess errors)
Excess errors:
/home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/string-1_b.C:5:23: internal
compiler error: unexpected expression '_Np' of kind template_parm_index
0x2fd136f internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:787
0xb3449e cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
../../gcc/cp/constexpr.cc:11395
0xb4540a cxx_eval_outermost_constant_expr
../../gcc/cp/constexpr.cc:11728
0xb4d070 maybe_constant_value(tree_node*, tree_node*, mce_value)
../../gcc/cp/constexpr.cc:12137
0xe38363 finish_bitint(unsigned long, tree_node*, bool, int)
../../gcc/cp/typeck.cc:12683
0xc8899c tree_node
../../gcc/cp/module.cc:10630
0xc8b8cd core_vals
../../gcc/cp/module.cc:7428
0xc8b8cd tree_node_vals
../../gcc/cp/module.cc:7900
0xc87b7a tree_value
../../gcc/cp/module.cc:10091
0xc87b7a tree_node
../../gcc/cp/module.cc:10481
0xc8c4ca key_mergeable
../../gcc/cp/module.cc:12266
0xc91d73 decl_value
../../gcc/cp/module.cc:8829
0xc87adc tree_node
../../gcc/cp/module.cc:10486
0xc90d06 module_state::read_cluster(unsigned int)
../../gcc/cp/module.cc:17817
The corresponding part of finish_bitint is:
tree
finish_bitint (location_t loc, tree prec, bool unsignedp,
tsubst_flags_t complain)
{
if (!type_dependent_expression_p (prec))
prec = build_converted_constant_expr (size_type_node, prec, complain);
prec = fold_non_dependent_expr (prec, complain, true);
Is it unsafe to call fold_non_dependent_expr during module reading?
If yes, maybe I should do
tree ret = make_node (BITINT_TYPE);
TYPE_PRECISION (ret) = 0;
TYPE_UNSIGNED (ret) = unsignedp;
BITINT_PREC (ret) = prec;
SET_TYPE_STRUCTURAL_EQUALITY (ret);
manually when streaming a dependent BITINT_TYPE instead of calling
finish_bitint.
Jakub