<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - UBSan reports downcast/upcast of misaligned address in std::set<long long>"
   href="https://llvm.org/bugs/show_bug.cgi?id=23413">23413</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UBSan reports downcast/upcast of misaligned address in std::set<long long>
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>public@hansmi.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14283" name="attach_14283" title="Test program and output after building with Clang 3.6 (using GCC toolchain 4.9)">attachment 14283</a> <a href="attachment.cgi?id=14283&action=edit" title="Test program and output after building with Clang 3.6 (using GCC toolchain 4.9)">[details]</a></span>
Test program and output after building with Clang 3.6 (using GCC toolchain 4.9)

Using `long long' as std::set's value type causes UBSan as included in Clang
3.5 and 3.6 to report an downcast/upcast of a misaligned address at runtime.

Platform: Debian 8 (Jessie) on Intel x86 (32 bit)
C++ library: libstdc++

Reproduced using:

- Clang 3.5 w/ GCC toolchain 4.9
- Clang 3.6 w/ GCC toolchain 4.9
- Clang 3.6 w/ GCC toolchain 5.1.0

The issue does not occur with libc++. Shorter value types for std::set, e.g.
`long' or `char', work. Packaging the `long long' in another type, e.g. a
struct, works too.

The fact that this is not reproducible when building with GCC 5.1.0 (with
-fsanitize=alignment) and neither when compiling for x86-64 leads me to believe
that this is an issue in Clang's implementation of UBSan.</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>