Add tests to demonstrate explicit tail call bug
This commit is contained in:
parent
907705abea
commit
3a02b357d3
2 changed files with 43 additions and 0 deletions
22
tests/ui/explicit-tail-calls/become-cast-return.rs
Normal file
22
tests/ui/explicit-tail-calls/become-cast-return.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//@ check-pass
|
||||
//@ ignore-backends: gcc
|
||||
//@ known-bug: #148239
|
||||
//@ compile-flags: -Zno-codegen
|
||||
#![expect(incomplete_features)]
|
||||
#![feature(explicit_tail_calls)]
|
||||
|
||||
#[inline(never)]
|
||||
fn leaf(_: &Box<u8>) -> [u8; 1] {
|
||||
[1]
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn dispatch(param: &Box<u8>) -> [u8; 1] {
|
||||
become leaf(param)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let data = Box::new(0);
|
||||
let out = dispatch(&data);
|
||||
assert_eq!(out, [1]);
|
||||
}
|
||||
21
tests/ui/explicit-tail-calls/become-indirect-return.rs
Normal file
21
tests/ui/explicit-tail-calls/become-indirect-return.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//@ run-pass
|
||||
//@ ignore-backends: gcc
|
||||
//@ known-bug: #148239
|
||||
#![expect(incomplete_features)]
|
||||
#![feature(explicit_tail_calls)]
|
||||
|
||||
#[inline(never)]
|
||||
fn op_dummy(_param: &Box<u8>) -> [u8; 24] {
|
||||
[1; 24]
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn dispatch(param: &Box<u8>) -> [u8; 24] {
|
||||
become op_dummy(param)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let param = Box::new(0);
|
||||
let result = dispatch(¶m);
|
||||
assert_ne!(result, [1; 24]); // the data is not right!
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue