http://llvm.org/bugs/show_bug.cgi?id=11313
Bug #: 11313
Summary: warning with conditional operator and printf
Product: clang
Version: trunk
Platform: PC
OS/Version: FreeBSD
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
The is a false positive in the format checker, when using conditional operator
and parameters get promoted.
There is more info in this thread:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-November/018464.html
--
clang -Wall -o ntohs2 ntohs2.c
ntohs2.c:10:12: warning: conversion specifies type 'unsigned short' but the
argument has type
'int' [-Wformat]
printf("%hu\n", x < 0 ? x : y);
~~^ ~~~~~~~~~~~~~
%d
1 warning generated.
--
#include <stdio.h>
#include <netinet/in.h>
int main()
{
uint16_t x = htons(80);
uint16_t y = ntohs(80);
x = x < 0 ? x : y;
printf("%hu\n", y);
printf("%hu\n", x < 0 ? x : y);
return (0);
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs