ICE ` in force_constant_size, at gimplify.cc`
Open
@philberty is already working on this.
Since Sep 15, 2026.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 230
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
const fn foo(n: usize) -> usize {
n * 2
}
fn bar<const N: usize>() -> [u32; foo(N)] {
[0; bar(N)]
}
original:
// revisions: full min
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(min, feature(min_const_generics))]
const fn foo(n: usize) -> usize { n * 2 }
fn bar<const N: usize>() -> [u32; foo(N)] {
//[min]~^ ERROR generic parameters may not be used in const operations
//[full]~^^ ERROR constant expression depends on a generic parameter
[0; bar(N)]
//[min]~^ ERROR generic parameters may not be used in const operations
}
fn main() {}
Version information:
5c3e2adc695b04a199d37cacd8c23b14fdab914f
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5c3e2adc695b04a199d37cacd8c23b14fdab914f/gcc/gimplify.cc#L799-L811
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
/tmp/icemaker_global_tempdir.fBJXTKLDiwA0/rustc_testrunner_tmpdir_reporting.xkPuZoVVCPIe/mvce.rs:6:9: error: this function takes 0 arguments but 1 argument was supplied [E0061]
6 | [0; bar(N)]
| ^~~
/tmp/icemaker_global_tempdir.fBJXTKLDiwA0/rustc_testrunner_tmpdir_reporting.xkPuZoVVCPIe/mvce.rs:6:5: error: mismatched types, expected ‘usize’ but got ‘<tyty::error>’ [E0308]
6 | [0; bar(N)]
| ^ ~~~
In function ‘mvce::bar’:
crab1: internal compiler error: in force_constant_size, at gimplify.cc:805
0x2fec938 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
../../gcc/diagnostic.cc:1803
0x97291f force_constant_size
../../gcc/gimplify.cc:805
0x1514e17 gimple_add_tmp_var(tree_node*)
../../gcc/gimplify.cc:843
0x14ad7f0 create_tmp_var(tree_node*, char const*)
../../gcc/gimple-expr.cc:487
0xc8a4f7 Backend::temporary_variable(tree_node*, tree_node*, tree_node*, tree_node*, bool, unsigned long, tree_node**)
../../gcc/rust/rust-gcc.cc:2072
0xc8a4f7 Backend::temporary_variable(tree_node*, tree_node*, tree_node*, tree_node*, bool, unsigned long, tree_node**)
../../gcc/rust/rust-gcc.cc:2051
0x118d749 Rust::Compile::HIRCompileBase::compile_function(bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tl::optional<Rust::HIR::SelfParam>&, std::vector<Rust::HIR::FunctionParam, std::allocator<Rust::HIR::FunctionParam> >&, Rust::HIR::FunctionQualifiers const&, Rust::HIR::Visibility&, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >&, unsigned long, Rust::HIR::BlockExpr*, Rust::Resolver::CanonicalPath const&, Rust::TyTy::FnType*)
../../gcc/rust/backend/rust-compile-base.cc:785
0x1157e91 Rust::Compile::CompileItem::visit(Rust::HIR::Function&)
../../gcc/rust/backend/rust-compile-item.cc:220
0xdce682 Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, unsigned long)
../../gcc/rust/backend/rust-compile-item.h:37
0xdce682 Rust::Compile::HIRCompileBase::query_compile(unsigned int, Rust::TyTy::BaseType*, Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool)
../../gcc/rust/backend/rust-compile-resolve-path.cc:248
0xdcf163 Rust::Compile::ResolvePathRef::resolve_with_node_id(Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool, unsigned int)
../../gcc/rust/backend/rust-compile-resolve-path.cc:200
0xdcf329 Rust::Compile::ResolvePathRef::resolve(Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool)
../../gcc/rust/backend/rust-compile-resolve-path.cc:232
0xdcf5eb tree_node* Rust::Compile::ResolvePathRef::resolve_path_like<Rust::HIR::PathInExpression>(Rust::HIR::PathInExpression&)
../../gcc/rust/backend/rust-compile-resolve-path.cc:68
0xdcf5eb Rust::Compile::ResolvePathRef::Compile(Rust::HIR::PathInExpression&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile-resolve-path.cc:46
0x115e1cf ???
../../gcc/rust/backend/rust-compile-expr.h:59
0x1167fcd Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile-expr.cc:48
0x1167fcd Rust::Compile::CompileExpr::visit(Rust::HIR::CallExpr&)
../../gcc/rust/backend/rust-compile-expr.cc:1322
0x1162ab6 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile-expr.cc:48
0x118e72f Rust::Compile::HIRCompileBase::compile_constant_item(unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
../../gcc/rust/backend/rust-compile-base.cc:869
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.