Floating-point values logged via os_log from Swift are wrong when viewed in Console app

Originator:jjc1138
Number:rdar://28763393 Date Originated:2016-10-13
Status:Open Resolved:
Product:macOS SDK Product Version:10.12 (16A323)
Classification:Other Bug Reproducible:Always
 
Summary:
When a floating-point value is logged via os_log from Swift code the value appears wrong when viewing the log in the Console app. Interestingly it appears correct in the Xcode console.

Steps to Reproduce:
1. Build and run the attached trivial repro project, which just runs the following on launch:
        os_log("%g", 0.1 as Double)
2. Open the Console app and filter for 'process:Swift Logging Test macOS' to find the log message.
3. Observe that the value in the logged message is wrong, and observe that the value in the Xcode console is correct

Expected Results:
0.1

Actual Results:
8.344027e-310

Version:
Xcode 8.0 (8A218a), macOS 10.12 (16A323)

Notes:


Configuration:
The same thing happens when running the app on the Mac itself, or when running an app on an attached iOS device. It doesn't happen when running an equivalent Objective-C test project.

Attachments:
'Swift Logging Test macOS.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!