[LLVMbugs] [Bug 12199] New: const strings not consolidated in -O0
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Mar 6 18:16:11 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12199
Bug #: 12199
Summary: const strings not consolidated in -O0
Product: clang
Version: 3.0
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: yingshen.yu at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
For the program below. clang 3.1 returns "different" unless you optimize it
with -O2 or higher. In gcc 4.2 and VC, the code always return "same" no
matter in -O0 or -O2.
Some code was written with this assumption, they know all the keys are from
const strings so they do pointer compare instead string compare. There're might
be more code relies on this behavior.
#include <stdio.h>
#define LAYER_KEY L"Layer"
struct TEST {
const wchar_t* key;
}gTESTINFO = {
LAYER_KEY
};
int main() {
const wchar_t* key = LAYER_KEY;
if (gTESTINFO.key == key)
printf("same\n");
else
printf("different\n");
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.
More information about the llvm-bugs
mailing list