[llvm-bugs] [Bug 40323] New: incorrect static object initialization on Windows
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 15 11:01:05 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40323
Bug ID: 40323
Summary: incorrect static object initialization on Windows
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: mib.bugzilla at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
This test case passes on Linux but fails on Windows, with -O0. When compiled
with the Microsoft compiler, the test case passes.
Output: Fail hist is 0 4
$ cat bug.cpp
#include <stdio.h>
long hist_ = 0;
template <class T>
struct X_ {
static T i;
static T init() { hist_ |= sizeof(T); return T(); }
};
template <class T> T X_<T>::i = X_<T>::init();
template struct X_<int>;
int main(int argc, char *argv[])
{
X_<int> my_var2;
if (hist_ != sizeof(int)) {
printf("Fail hist is %d %d\n", hist_, sizeof(int));
// On Windows, this exit is taken
return 4;
} else
printf("Pass hist is %d %d\n", hist_, sizeof(int));
return 0;
}
--
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/20190115/f84b9a7f/attachment.html>
More information about the llvm-bugs
mailing list