http://llvm.org/bugs/show_bug.cgi?id=21330
Bug ID: 21330
Summary: clang-cl miscompiles insertion of struct value into
std::map
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
Classification: Unclassified
Example derived from a Chromium unit test:
#include <map>
#include <stdio.h>
#include <string>
struct CrashKey {
const char *name;
size_t val;
};
std::map<std::string, CrashKey> map;
int main() {
const CrashKey keys[] = { { "foo", 42 }, { "bar", 7 } };
for (int i = 0; i < sizeof keys / sizeof keys[0] ; ++i)
map.insert(std::make_pair(keys[i].name, keys[i]));
for (auto i : map)
printf("key: %s, %d\n", i.second.name, i.second.val);
return 0;
}
Compiled with clang-cl /Ox, this prints
key: bar, 0
key: foo, 0
Compiled without optimization, or with MSVC, it prints:
key: bar, 7
key: foo, 42
I think this regressed sometime last night.
--
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