ICE: `in add_fragment, at rust/expand/rust-macro-expand.cc:1185`
Open
@powerboat9 is already working on this.
Since Mar 26, 2025.
bug
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
macro_rules! print_hd_tl {
($field_hd:ident, $($field_hd:ident),+) => {};
}
pub fn main() {
print_hd_tl!(x, y, z, w)
}
original:
// run-pass
macro_rules! print_hd_tl {
($field_hd:ident, $($field_hd:ident),+) => ({
print!("{}"$field_hd:ident stringify!($field_hd));
print!("::[");
$(
print!("{}", stringify!($field_hd));
print!(", ");
)+
print!("]\n");
})
}
pub fn main() {
print_hd_tl!(x, y, z, w)
}
Version information:
a988708b4ba2b5a27715ea34c09ccfd3ed5143ca
Command:
crab1 -Warray-bounds -mtune=generic -march=x86-64 -O0 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
crab1: internal compiler error: in add_fragment, at rust/expand/rust-macro-expand.cc:1185
0x864325 Rust::MatchedFragmentContainer::add_fragment(std::unique_ptr<Rust::MatchedFragmentContainer, std::default_delete<Rust::MatchedFragmentContainer> >)
../../gcc/rust/expand/rust-macro-expand.cc:1185
0x864325 Rust::MatchedFragmentContainer::add_fragment(std::unique_ptr<Rust::MatchedFragmentContainer, std::default_delete<Rust::MatchedFragmentContainer> >)
../../gcc/rust/expand/rust-macro-expand.cc:1182
0x864325 Rust::SubstitutionScope::append_fragment(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::unique_ptr<Rust::MatchedFragmentContainer, std::default_delete<Rust::MatchedFragmentContainer> >)
../../gcc/rust/expand/rust-macro-expand.h:263
0x864325 Rust::MacroExpander::match_n_matches(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatchRepetition&, unsigned long&, unsigned long, unsigned long)
../../gcc/rust/expand/rust-macro-expand.cc:655
0xc816d3 Rust::MacroExpander::match_repetition(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatchRepetition&)
../../gcc/rust/expand/rust-macro-expand.cc:763
0xc81a18 Rust::MacroExpander::match_matcher(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatcher&, bool, bool)
../../gcc/rust/expand/rust-macro-expand.cc:533
0xc82232 Rust::MacroExpander::match_matcher(Rust::Parser<Rust::MacroInvocLexer>&, Rust::AST::MacroMatcher&, bool, bool)
/usr/include/c++/14.2.1/bits/stl_construct.h:162
0xc82232 Rust::MacroExpander::try_match_rule(Rust::AST::MacroRule&, Rust::AST::DelimTokenTree&)
../../gcc/rust/expand/rust-macro-expand.cc:376
0xc82433 Rust::MacroExpander::expand_decl_macro(unsigned int, Rust::AST::MacroInvocData&, Rust::AST::MacroRulesDefinition&, Rust::AST::InvocKind)
../../gcc/rust/expand/rust-macro-expand.cc:90
0xc8324b Rust::MacroExpander::expand_invoc(Rust::AST::MacroInvocation&, Rust::AST::InvocKind)
../../gcc/rust/expand/rust-macro-expand.cc:305
0xd392a4 Rust::ExpandVisitor::maybe_expand_expr(std::unique_ptr<Rust::AST::Expr, std::default_delete<Rust::AST::Expr> >&)
../../gcc/rust/expand/rust-expand-visitor.cc:339
0xd3db00 void Rust::ExpandVisitor::expand_macro_children<std::vector<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >, std::allocator<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > > >, std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > >(std::vector<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >, std::allocator<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > > >&, std::function<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > (Rust::AST::SingleASTNode)>)
../../gcc/rust/expand/rust-expand-visitor.h:133
0xd3db00 Rust::ExpandVisitor::expand_inner_items(std::vector<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> >, std::allocator<std::unique_ptr<Rust::AST::Item, std::default_delete<Rust::AST::Item> > > >&)
../../gcc/rust/expand/rust-expand-visitor.cc:239
0xc460f5 Rust::Session::expansion(Rust::AST::Crate&, Rust::Resolver2_0::NameResolutionContext&)
../../gcc/rust/rust-session-manager.cc:959
0xc5bc91 Rust::Session::compile_crate(char const*)
../../gcc/rust/rust-session-manager.cc:619
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.