Skip to content

[SR-452] Recursive function without base case returns garbage value when compiled with -O #43069

@swift-ci

Description

@swift-ci
Previous ID SR-452
Radar None
Original Reporter loic (JIRA User)
Type Bug
Environment

Swift 2.2-dev (December 31)
OS X El Capitan

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, OptimizedOnly
Assignee None
Priority Medium

md5: 546cfc45f510272795c24cb4aa0daa3d

Issue Description:

This code will crash (segfault) when compiled with -Onone, but returns garbage when compiled with -O.

func rec(x: Int) -> Int {
    return rec(x)
}
print(rec(0))

I think it should always crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfoptimized onlyFlag: An issue whose reproduction requires optimized compilation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions