Skip to content

getting parity of signed integer maximum or minimum results in stack overflow #37991

Closed
@est31

Description

@est31

Some examples that cause rustc to overflow its stack:

assert_eq!(i64::max_value() % 2, 1);
assert_eq!(i64::min_value() % 2, 0);

Give error message at compile time:

thread 'rustc' has overflowed its stack

Gives a stack overflow too if you use i8,i16,i32, but it can't be reproduced with unsigned types.

Also, this doesn't reproduce the stack overflow either:

let m = i64::min_value();
assert_eq!(m % 2, 0);

This dates back to at least rustc 1.12 stable, and is reproducible with recent nightly as well.

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-highHigh 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

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions