[LLVMbugs] [Bug 12548] New: clang++ -fshort-wchar results in unsigned wchar_t arithmetic (missing integral promotion)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Apr 13 05:17:14 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12548
Bug #: 12548
Summary: clang++ -fshort-wchar results in unsigned wchar_t
arithmetic (missing integral promotion)
Product: clang
Version: 3.0
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: anders at opera.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
#include <stdlib.h>
#include <stdio.h>
int compare(void const* ap, void const* bp) {
const wchar_t *a=(const wchar_t *)ap, *b=(const wchar_t *)bp;
while (*a && *b && (*a == *b)) {
++a; ++b;
}
return *a-*b;
}
int main() {
const wchar_t* fruit[] = { L"apricot",L"banana" };
printf("%d %d\n", L'a'-L'b', compare(fruit[0], fruit[1]));
qsort(fruit, 2, sizeof(wchar_t*), compare);
return 0;
}
$ clang++ -Wall -fshort-wchar -o wchar wchar.cpp
wchar.cpp:14:11: warning: conversion specifies type 'int' but the argument has
type 'wchar_t' [-Wformat]
printf("%d %d\n", L'a'-L'b', compare(fruit[0], fruit[1]));
~^ ~~~~~~~~~
1 warning generated.
$ ./wchar
65535 65535
$ g++ -Wall -fshort-wchar -o wchar wchar.cpp
$ ./wchar
-1 -1
Probably related to Bug 8856
--
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.
More information about the llvm-bugs
mailing list