segfault in `Rust::Resolver::TypeCheckContext::LifetimeResolver::get_num_bound_regions
Open
@philberty is already working on this.
Since Jul 31, 2025.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
struct Foo<
const N: [u8; {
impl Foo<N> {}
}],
>;
original:
//@ revisions: full min
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Foo<const N: [u8; {
struct Foo<const N: usize>;
impl<const N: usize> Foo<N> {
fn value() -> usize {
struct Foo<const N: usize>;
impl<const N: usize> Foo<N> {
fn value() -> usize {
N
}
}
Foo::<17>::value()
//~^ ERROR cannot call non-const associated function
}
}
Foo::<17>::value()
//~^ ERROR cannot call non-const associated function
}]>;
//[min]~^^^^^^^^^^^^ ERROR `[u8; {
// N.B. it is important that the comment above is not inside the array length,
// otherwise it may check for itself, instead of the actual error
fn main() {}
Version information:
5dc8c4d20d62462ebce137c6e5146235ab9e9e2e
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
/tmp/icemaker_global_tempdir.EftwEJgsVgUM/rustc_testrunner_tmpdir_reporting.9m3FtiGblWyP/mvce.rs:3:14: error: failed to resolve type path segment: ‘Foo<>’
3 | impl Foo<N> {}
| ^~~
/tmp/icemaker_global_tempdir.EftwEJgsVgUM/rustc_testrunner_tmpdir_reporting.9m3FtiGblWyP/mvce.rs:2:19: error: mismatched types, expected ‘usize’ but got ‘()’ [E0308]
2 | const N: [u8; {
| ^
crab1: internal compiler error: Segmentation fault
0x2fecaf8 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0x196d57f crash_signal
../../gcc/toplev.cc:321
0x1080b6e Rust::Resolver::TypeCheckContext::LifetimeResolver::get_num_bound_regions() const
../../gcc/rust/typecheck/rust-hir-type-check.h:393
0x1080b6e Rust::Resolver::TypeCheckItem::visit(Rust::HIR::StructStruct&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:319
0x106e185 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0x1119fc3 Rust::Resolver::query_type(unsigned int, Rust::TyTy::BaseType**)
../../gcc/rust/typecheck/rust-type-util.cc:62
0x1083aae Rust::Resolver::TypeCheckType::resolve_root_path(Rust::HIR::TypePath&, unsigned long*, bool*)
../../gcc/rust/typecheck/rust-hir-type-check-type.cc:419
0x1085d5f Rust::Resolver::TypeCheckType::visit(Rust::HIR::TypePath&)
../../gcc/rust/typecheck/rust-hir-type-check-type.cc:140
0x1082477 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
../../gcc/rust/typecheck/rust-hir-type-check-type.cc:71
0x10838b7 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
../../gcc/rust/typecheck/rust-hir-type-check-type.cc:67
0x106ea87 Rust::Resolver::TypeCheckItem::resolve_impl_block_substitutions(Rust::HIR::ImplBlock&, bool&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:787
0x1078567 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ImplBlock&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:519
0x106e185 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0x10a9c8b ???
../../gcc/rust/typecheck/rust-hir-type-check-stmt.h:47
0x10aa163 Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt&)
../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
0x109beb4 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:601
0x109a4d4 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x10830b0 Rust::Resolver::TypeCheckType::visit(Rust::HIR::ArrayType&)
../../gcc/rust/typecheck/rust-hir-type-check-type.cc:698
0x1082477 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
../../gcc/rust/typecheck/rust-hir-type-check-type.cc:71
0x10838b7 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
../../gcc/rust/typecheck/rust-hir-type-check-type.cc:67
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.