Skip to content

Internal Compiler Error: 'attempt to subtract with overflow', compiler/rustc_session/src/session.rs:478:22 #84219

Closed
@dwrensha

Description

@dwrensha

Build rustc with overflow checking enabled:

RUSTFLAGS="-C overflow-checks=on" ./x.py build --stage 1

Then try compiling the following program (found by fuzz-rustc):

const M;
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc bug.rs 
error: free constant item without body
 --> bug.rs:1:1
  |
1 | const M;
  | ^^^^^^^-
  |        |
  |        help: provide a definition for the constant: `= <expr>;`

error[E0601]: `main` function not found in crate `bug`
 --> bug.rs:1:1
  |
1 | const M;
  | ^^^^^^^^ consider adding a `main` function to `bug.rs`

thread 'rustc' panicked at 'attempt to subtract with overflow', /home/dwrensha/src/rust/compiler/rustc_session/src/session.rs:475:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-dev running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0601`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions