ICE in expand_message, at rust/rust-diagnostics.cc
Nobody has claimed this yet.
- 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
fn main() {
let _ = [(); {
let mut n = 113383;
while n != 0 {
n = if if {
let mut n = 113383;
while n != 0 {
n = if if n % 2 == 0 { n / 2 } else { 3 * n + 1 } % 2 == 0 {
n / 2
} else {
3 * n + 1
};
}
n
} == 0
{
n / 2
} else {
3 * n + 1
} % 2
== 0
{
n / 2
} else {
3 * n + 1
};
}
n
}];
}
original:
fn main() {
// Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
// The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
let _ = [(); {
let mut n = 113383; // #20 in https://oeis.org/A006884
while n != 0 {
n = if if {
let mut n = 113383; // #20 in https://oeis.org/A006884
while n != 0 {
n = if if n % 2 == 0 { n/2 } else { 3*n + 1 } % 2 == 0 { n/2 } else { 3*n + 1 };
//~^ ERROR evaluation of constant value failed
}
n
} == 0 { n/2 } else { 3*n + 1 } % 2 == 0 { n/2 } else { 3*n + 1 };
//~^ ERROR evaluation of constant value failed
}
n
}];
}
Version information:
dbf131a5d5398ff98556b301304f28d16cef18cc
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/dbf131a5d5398ff98556b301304f28d16cef18cc/gcc/rust/rust-diagnostics.cc#L125-L137
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
crab1: error: memory allocation failed in vasprintf
crab1: internal compiler error: in expand_message, at rust/rust-diagnostics.cc:131
0x3073c69 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:787
0xc36943 fancy_abort(char const*, int, char const*)
../../gcc/diagnostics/context.cc:1806
0xcab899 expand_message
../../gcc/rust/rust-diagnostics.cc:131
0xcab899 expand_message
../../gcc/rust/rust-diagnostics.cc:121
0xcac3e0 rust_error_at(unsigned long, char const*, ...)
../../gcc/rust/rust-diagnostics.cc:198
0x1169979 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:1970
0x1169356 eval_statement_list
../../gcc/rust/backend/rust-constexpr.cc:4877
0x1169356 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2261
0x11687bf eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2265
0x1169356 eval_statement_list
../../gcc/rust/backend/rust-constexpr.cc:4877
0x1169356 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2261
0x11687bf eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2265
0x1168a57 eval_loop_expr
../../gcc/rust/backend/rust-constexpr.cc:5113
0x1168a57 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2395
0x1169356 eval_statement_list
../../gcc/rust/backend/rust-constexpr.cc:4877
0x1169356 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2261
0x11687bf eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2265
0x1169356 eval_statement_list
../../gcc/rust/backend/rust-constexpr.cc:4877
0x1169356 eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2261
0x11687bf eval_constant_expression
../../gcc/rust/backend/rust-constexpr.cc:2265
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.
Research direction
Start with the reduced Rust reproducer and command in the issue, then inspect expand_message in gcc/rust/rust-diagnostics.cc around lines 125-137. Trace the vasprintf failure and the diagnostic path shown in the backtrace. Done means the reproducer no longer triggers an internal compiler error in expand_message and reports the underlying failure appropriately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100