File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,19 @@ fn force_stack_overflow(depth: u32) {
15
15
}
16
16
}
17
17
18
+ #[ cfg( unix) ]
19
+ fn overflow_code ( ) -> Option < i32 > {
20
+ None
21
+ }
22
+
23
+ #[ cfg( windows) ]
24
+ fn overflow_code ( ) -> Option < i32 > {
25
+ use std:: os:: windows:: process:: ExitStatusExt ;
26
+ use std:: process:: ExitStatus ;
27
+
28
+ ExitStatus :: from_raw ( 0xc00000fd /*STATUS_STACK_OVERFLOW*/ ) . code ( )
29
+ }
30
+
18
31
fn main ( ) {
19
32
if env:: args ( ) . len ( ) == 1 {
20
33
// first check that the recursivecall actually causes a stack overflow, and does not get optimized away
@@ -24,11 +37,8 @@ fn main() {
24
37
. status ( )
25
38
. unwrap ( ) ;
26
39
27
- #[ cfg( windows) ]
28
- assert_eq ! ( status. code( ) , Some ( 0xc00000fd /*STATUS_STACK_OVERFLOW*/ ) ) ;
29
-
30
- #[ cfg( unix) ]
31
- assert_eq ! ( status. code( ) , None ) ;
40
+ #[ cfg( any( unix, windows) ) ]
41
+ assert_eq ! ( status. code( ) , overflow_code( ) ) ;
32
42
33
43
#[ cfg( target_os = "linux" ) ]
34
44
assert ! (
You can’t perform that action at this time.
0 commit comments