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

    <tr>
        <th>Summary</th>
        <td>
            #pragma init_seg(section-specifier, func-name) not supported
        </td>
    </tr>

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

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

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

<pre>
    This MSVC pragma is only partially implemented. As detailed here, there is functionality to specify a function to call in place of atexit.

https://learn.microsoft.com/en-us/cpp/preprocessor/init-seg?view=msvc-170

"func-name
Specifies a function to be called in place of atexit when the program exits. This helper function also calls [atexit](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/atexit?view=msvc-170) with a pointer to the destructor for the global object. If you specify a function identifier in the pragma of the form,

C++

Copy
int __cdecl myexit (void (__cdecl *pf)(void))
then your function will be called instead of the C run-time library's atexit. It allows you to build a list of the destructors to call when you're ready to destroy the objects."

Relevant code in ParsePragma.cpp:Parser::HandlePragmaMSInitSeg:
    // FIXME: Add support for the '[, func-name]' part of the pragma.

Maybe a good early OSS contribution given the limited use and lack of potential for regression

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVM-OszYQfxrnMgoiJmzCgQObbdo9rPqpqareVoM9ELfGRrZJyttXNmS3236XSpEATzz-_fOg96o3RDUrn1n5ssEpXK2rG4nDjxq937RWzvWvV-Xh7fLbCUaH_YCgPFijZxjRBYVaz6CGUdNAJpDMoPEgKaDSJOFKjhg_QYgvcWM3GRGUNahVmCFY8CMJ1c2AH6W4KlBrUAZGjYLAdoCB_lIhY3nD8uYawuhZ0TB-ZvysCZ3JBiWc9bYLmbAD42cy28kzfhbjyPh5dDQ6K8h76xg_K6PC1lPPivNN0Z0VL4O_ie3ukC8HMM4jmq3BgVjeXBJGRf5fKFtKQEl-Byrcr2Qibxid7R0OEFd9Bkn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