<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ms] #pragma bss_seg fails to apply to globals with user provided constructors"
   href="https://bugs.llvm.org/show_bug.cgi?id=41865">41865</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ms] #pragma bss_seg fails to apply to globals with user provided constructors
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider:

$ cat t.cpp
struct Foo {
  int x, y;
  Foo() : x(1), y(2) {}
};
#pragma bss_seg("my_bss")
Foo gv;

$ cl -c t.cpp  && dumpbin t.obj | grep bss
Microsoft (R) C/C++ Optimizing Compiler Version 19.20.27508.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t.cpp
           8 my_bss

$ clang-cl -c t.cpp  && dumpbin t.obj | grep bss
           8 .bss

Clang thinks `gv` has an initializer, so it would apply the most recently
active data_seg pragma, instead of bss_seg. The code to control this is here:
<a href="https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaDecl.cpp#L11926">https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaDecl.cpp#L11926</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>