<html>
    <head>
      <base href="http://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 --- - Enumeration constants emitted with the wrong sign/extension"
   href="http://llvm.org/bugs/show_bug.cgi?id=19712">19712</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Enumeration constants emitted with the wrong sign/extension
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>DebugInfo
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dblaikie@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>aprantl@apple.com, echristo@gmail.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When emitting a debug info constant (DwarfUnit::addConstantValue) we interpret
the 64 bits of immediate as signed or unsigned based on the type.

We don't emit the underlying type of an enum, so we just assume the type is one
way or the other (DwarfUnit.cpp:isUnsignedDIType - we assume that the type is
signed).

This means we get this wrong: 

  enum x { y = 4294967295U };
  x z;

By describing the constant as -1 (assuming the 64 bit constant was signed)

0x0000003b:     DW_TAG_enumerator [4]  
                  DW_AT_name [DW_FORM_strp]     ( .debug_str[0x0000002e] = "y")
                  DW_AT_const_value [DW_FORM_sdata]     (-1)

FWIW: GCC always produces sdata constants by the looks of it, but it gets it
right by producing a larger constant, rather than using a possibly smaller
udata (even if the enum's underlying type is an unsigned type) value.</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>