Clang: spurious warnings about %m format specifier with asl_log

Originator:frankoid
Number:rdar://7341605 Date Originated:27-Oct-2009
Status:Open Resolved:
Product:Developer Tools Product Version:3.2.1
Classification:Other Bug Reproducible:Always
 
Summary:
The Clang LLVM 1.0 compiler warns when %m is included in the format argument to asl_log even though %m is valid there (it is replaced with the current error message).

Steps to Reproduce:
1. Open Xcode 3.2.1
2. Create a new Command Line Tool project
3. Change main.c to the following:
#include <stdio.h>
#include <asl.h>

int main (int argc, const char * argv[]) {
    aslclient asl = asl_open(NULL, "FormatStringWarning", ASL_OPT_STDERR);
    
    asl_log(asl, NULL, ASL_LEVEL_ERR, "Error: %m");
    
    asl_close(asl);
    return 0;
}
4. Select the project in the left hand pane and press Cmd-I to open the project info window.
5. Choose "Clang LLVM 1.0" as the "C/C++ Compiler Warning".
6. Press Cmd-B to build the project.

Expected Results:
The project should build without errors or warnings.

Actual Results:
The project builds without errors but the following warning is issued:
/Users/francis/Code/BugReports/FormatStringWarning/main.c:7:47 /Users/francis/Code/BugReports/FormatStringWarning/main.c:7:47:{7:39-7:50}: warning: invalid conversion '%m' [-Wformat]

Regression:
Does not occur with GCC 4.2.

Notes:
Example project attached.


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!