Issue 91418
Summary [clang][PCH] Initialization order issue after change to lazy initializer loading
Labels clang
Assignees
Reporter wolfy1961
    After commit [bc73ef0031](https://github.com/llvm/llvm-project/commit/bc73ef0031b50f7443615fef614fb4ecaaa4bd11) we see an incorrect initialization order with the attached code. This occurs with PCH use only.

With a vanilla native clang with the above commit on Ubuntu 22.04:

clang -fmath-errno -o t.pch -x c++-header t.h
clang -fmath-errno -S t.cpp -include-pch t.pch
clang -o t t.s -lm
./t

we get the expected

p:0.225000
a:7.589466
b:1.633843
A:7.589466 7.589466 7.589466 7.589466
B:1.633843 1.633843 1.633843 1.633843

But with

clang -fno-math-errno -o t.pch -x c++-header t.h
clang -fno-math-errno -S t.cpp -include-pch t.pch
clang -o t t.s -lm
./t

we get 

p:0.225000
a:7.589466
b:1.633843
A:0.000000 0.000000 0.000000 0.000000
B:0.000000 0.000000 0.000000 0.000000

Looking at the code the vectors 'A' and 'B' are initialized before 'a' and 'b' in the failing example.
[init.zip](https://github.com/llvm/llvm-project/files/15242786/init.zip)


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to