https://bugs.llvm.org/show_bug.cgi?id=51770

            Bug ID: 51770
           Summary: [codeview] Invalid encoding of signed ints when
                    emitting S_CONSTANTs
           Product: libraries
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: DebugInfo
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected],
                    [email protected]

Signed integers are incorrectly encoded to CodeView S_CONSTANTs.

Tracked down to this commit
https://github.com/llvm/llvm-project/commit/7156910d85fcafdc78371a852c00a7184f8563cd

Before this commit the constant values were encoded as expected.

Clang 12.x: S_CONSTANT: Type: T_INT4(0074), Value: (LF_CHAR) -128(0x80), E1
Clang 10.x: S_CONSTANT: Type: T_INT4(0074), Value: 128, E1

The following example demonstrates the problem.

enum {
  E0 = 127, // OK: 127
  E1 = 128, // FAIL: -128
  E2 = 129, // FAIL: -127
  E3 = 254, // FAIL: -2
  E4 = 255, // FAIL: -1
  E5 = 256, // FAIL: 0
  E6 = 257, // FAIL: 1
  E7 = 511, // FAIL: -1
  E8 = 512, // FAIL: 0
  E9 = 513, // FAIL: 1
};

int main() {
   return E0 + E1 + E2 + E3 + E4 + E5 + E6 + E7 + E8 + E9; // ensure usage
};

(Separately, note that LLDB has a bug / missing feature where it is unable to
resolve any of these S_CONSTANTs giving the error "use of undeclared
identifier").

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to