Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13481] SwiftPM: Assertion behaviour inconsistent between swift and C/C++ #4504

Open
benlangmuir opened this issue Sep 1, 2020 · 3 comments
Labels

Comments

@benlangmuir
Copy link
Member

Previous ID SR-13481
Radar rdar://problem/68159829
Original Reporter @benlangmuir
Type Bug

Attachment: Download

Environment

Swift 5.3, Xcode 12

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 88f80158fc8eac071055b74bfae5d006

Issue Description:

Building a package with --configuration release disables assertions in Swift code, but not in C/C++/ObjC.

The behaviour should be consistent across languages, and we should introduce a separate command-line option to explicitly control assertions for both swift and clang in release builds, since it is often useful to test in release+asserts.

$ swift test -c release
...
Assertion failed: (0 && "c assert"), function cFunc, file /private/tmp/asserts/Sources/casserts/casserts.c, line 5.
Exited with signal code 6

While in debug, assertions are enabled for both

$ swift test
...
Fatal error: swift assert: file asserts/asserts.swift, line 2
Exited with signal code 4
...
Assertion failed: (0 && "c assert"), function cFunc, file /private/tmp/asserts/Sources/casserts/casserts.c, line 5.
Exited with signal code 6
@benlangmuir
Copy link
Member Author

Workaround to disable assertions in release builds:

cSettings: [
    .define("NDEBUG", to: "1", .when(configuration: .release))
]),

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@benlangmuir
Copy link
Member Author

Reproduces in 5.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants