<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 - __STDCPP_DEFAULT_ALIGNED_NEW__ on Windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=35356">35356</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__STDCPP_DEFAULT_ALIGNED_NEW__ on Windows
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>5.0
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Casey@Carter.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang 5.0.0 -m64 defines __STDCPP_DEFAULT_NEW_ALIGNMENT__ incorrectly when
using the MSVC standard libraries. This will become an interop problem when
Visual Studio 2017 version 15.5 ships since it includes support for overaligned
new: there is potential for ODR violations when clang TUs with
__STDCPP_DEFAULT_NEW_ALIGNMENT__ defined to 8 link with C1XX TUs with
__STDCPP_DEFAULT_NEW_ALIGNMENT__ defined to 16. I've almost finished
implementing <memory_resource> for a future release, and I've observed the
results of said ODR violations first-hand when linking a test compiled with
Clang to the separately-C1XX-compiled bits in the library.

It appears that Clang is always using the value 8 - which happens to be
alignof(max_align_t) for both x86 and x64 flavors of the MSVC STL - instead of
the proper (2 * sizeof(void *)) which is the alignment guaranteed by malloc
(and the default implementation of operator new in vcruntime that simply calls
malloc).

I'm not sure how or if Clang detects that it's using the MSVC STL vs. libc++ on
Windows, and I'm unsure if libc++ on Windows implements operator new other than
by calling malloc in the CRT. It would be a good idea to check with such
stakeholders before simply changing the value of
__STDCPP_DEFAULT_NEW_ALIGNMENT__ out from under them.</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>