<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/110975>110975</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang][c++17] const static inline variable initialization order
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mprettner-huawei
      </td>
    </tr>
</table>

<pre>
    The following code produces a non-intuitive output when running with Clang19 on Windows:
```c++
#include <iostream>

struct A
{
    int m_value;

    A(int value) : m_value(value)
    {
 std::cout << "A::A(" << value << ")\n";
    }

    int GetValue() const
    {
        std::cout << "A::GetValue() -> " << m_value << "\n";
        return m_value;
    }
};

struct B
{
    const static inline A a = A(1);
    const static inline int b = a.GetValue();
};

int main()
{
    std::cout << "Result: " << B::b << "\n";
    return 0;
}
```

The following output is generated:
```
A::GetValue() -> 0
A::A(1)
Result: 0
```
According to my understanding of the C++ standard this code should be correct and the output should be "A::A, A::GetValue, Result", but with Clang19 on Windows the order of GetVaule and the constructor is swapped, which leads to the wrong result. The same code works correctly with Clang on Linux and MSVC on Windows.

Platform:
* Windows 10 22H2
* Clang installer from Github (LLVM-19.1.0-win64.exe)
* Visual Studio build tools 2022 (17.9.6)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVctu4zYU_Rpqc2GBoqTYWmjhx2S6mAGKTpEuC4qkLbYUafBhTfr1BSkllmO3EYREJu89POe-SJ2TJy1Ei-odqg8ZDb43th3OVnivhV31gY5CZp3hr-3vvYCjUcqMUp-AGS7gbA0PTDigoI1eSe2D9PIiwAR_Dh7GXmiwQevoMUrfw15RfSoaMBr-kJqb0aFyi_AB4S16wtPLENnFd1olpdRMBS4AlXtpnLeCDqj8Mm-nv87bwDy8Aa1nXwAAqT0Mf16oCgKVu6VT3N0isokW0z5pAJXbd3OyeVu-OlyxneeRerllJvj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