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

    <tr>
        <th>Summary</th>
        <td>
            The inialization order of the the "static inline" data members vs CRT is not right
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          ujos
      </td>
    </tr>
</table>

<pre>
    It seems the initialization order of the `static inline` variables is not in line with C-Runtime initialization. 

```txt
clang version 14.0.4
Target: x86_64-w64-windows-gnu
Thread model: posix
```

When I compile and run the following code, it prints nothing. Apparently application crashes during the initialization of the `C1::f1` while printing to the `std::cout`

```cpp

// clang++ --std=c++17 2.cpp -o 2.exe

#include <iostream>

struct Field
{
    Field(char const* name) { std::cout << name << "\n"; }
};

struct C1 
{
    static inline const Field f1{"C1::f1"};
};

int main()
{
    std::cout << "Exit\n";
}
```

In case if I remove the body of the `Field::Field` constructor, code compiles and runs just fine.

In case if I convert `static inline` into `static`, code compiles and runs just fine.

```cpp
#include <iostream>

struct Field
{
    Field(char const* name) { std::cout << name << "\n"; }
};

struct C1 
{
    static const Field f1;
};

const Field C1::f1{"C1::f1"};

int main()
{
    std::cout << "Exit\n";
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdVU2P2yAQ_TX2ZRTLwfk8-JBNdqW9rlbqscJmbLPCYAFOsv31HeNN89FEVS89NCI2MMPMm8czFEZ85q8eHGLrwDcIUksvuZI_uJdGg7ECLZgq2KJF6jzNl-SlpEYaw55byQuFDqQDbTyZYLDBQfoGtpO3XnvZ3sZNIEp3Ubr5ei7SsfmjH2dKxXUNe7RuADGdJWkyGy3v3Nboo2wDx9Xi-2I2OQx_qYU5uEmt-y-vxiIX0BqBavDtjJPHm2SXCL41qOEVStN2UiFwLcD2OhRdGaUMJajJKjBiW5AeOiu1D_U2ZElg03XcovbqE3jXKVmO7JWWu4aoEb0dAtzj9xez2ykBpVZNB1oPzYAjpAkrzXkDxOhXmt7fVPGrtLLrrubZCzUIpEbsiRpMJiHQrhzH0yWwhFbBxFAHj3i9PJO6VL0gANlWGueJ3DbKni-daLIvPbxIVOJrfvk0doB-4zxblQ23RKR2PmIb0LwlRtdArnBV2JCIWnA49SPGovlWD6_siZbsTml2NL4DZTuFO0CuBDwiGcEBEU-OjF1sBKW6jP5bJtodaLkkTCsq4262O0VR2Oej9OdizuEfK_SV1MQd6acinVpszR6DJAr6gi9UNPIcUo5d0lIocqDE2EG-g4xPSncnqTv46ImJikhJHqalQPRJ-rvnAFFhzoYB_N-muqPe_1B4N4p7rK1LxwtJ_kGi_0KWscgzsc7WPPbSK8zfx2PtwaURhMnYtWAYA8E9hxbbgg552DvYvr2frhAr68bHvVV5433nBqjhBKvpSumLhARFA6X2p9eks-YDS9rZF-lcj44680WWruMmL8S8wiWmWVZOi7Xg2ayqylU640JMWbqYxYoXqFwezQdiNR4ghAh7votlzlJGblk6nVFbJativVinSyxFWmQVYjRLkahWyYAjMbaObR4gFX3tyKik8-5s5M7JWiOGdBSf974xNu8_jItD3jzg_glsvTax">