[LLVMbugs] [Bug 23177] New: static char strange linker error
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Apr 9 12:38:01 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23177
Bug ID: 23177
Summary: static char strange linker error
Product: lld
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: release blocker
Priority: P
Component: All Bugs
Assignee: unassignedbugs at nondot.org
Reporter: daniel.liverance at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
I'm using Xcode on Apple LLVM version 6.1.0 (clang-602.0.49) based on LLVM
3.6.0svn
There is a strange linker error with the following code:
#include <stdio.h>
#include <map>
class Foo
{
public:
static const char Something = 0;
};
std::map<char, int> test_fail;
int main(int argc, const char * argv[])
{
if (Foo::Something == 0)
{
char bar = Foo::Something;
printf("Foo::Something = %d\n", bar);
printf("Foo::Something = %d\n", Foo::Something);
test_fail[Foo::Something] = 0;
}
return 0;
}
This program fails to link on the symbol Foo::Something in _main, and it's odd
because it only fails to link when using it with the std::map.
If you comment out "test_fail[Foo::Something] = 0;" it successfully links.
It will also link if you change:
static const char Something = 0;
to:
static const unsigned char Something = 0;
It will also link if you change:
std::map<char, int> test_fail;
to:
std::map<unsigned char, int> test_fail;
It will also compile if you cast the Foo::Something in the map usage like:
test_fail[(char)Foo::Something] = 0;
test_fail[(unsigned char)Foo::Something] = 0;
both will fix the linker error.
I believe this is a bug in the linker.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150409/46ed0752/attachment.html>
More information about the llvm-bugs
mailing list