-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add invariant to Vec::pop that len < cap if pop successful
Fixes: #114334
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
#[no_mangle] | ||
pub fn noop(v: &mut Vec<u8>) { | ||
// CHECK: start: | ||
// CHECK-NEXT: getelementptr | ||
// CHECK-NEXT: load | ||
// CHECK-NEXT: icmp eq | ||
// CHECK-NEXT: br | ||
|
||
// CHECK: add | ||
// CHECK-NEXT: getelementptr | ||
// CHECK-NEXT: load | ||
// CHECK-NEXT: icmp | ||
// CHECK-NEXT: tail call | ||
// CHECK-NEXT: br label %bb3 | ||
|
||
// CHECK: bb3: | ||
// CHECK-NEXT: ret void | ||
if let Some(x) = v.pop() { | ||
v.push(x) | ||
} | ||
} |