http://llvm.org/bugs/show_bug.cgi?id=19712

            Bug ID: 19712
           Summary: Enumeration constants emitted with the wrong
                    sign/extension
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: DebugInfo
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to