[llvm-bugs] [Bug 51770] New: [codeview] Invalid encoding of signed ints when emitting S_CONSTANTs

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 6 09:15:18 PDT 2021


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: unassignedbugs at nondot.org
          Reporter: remedybg at protonmail.com
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210906/0167c0fe/attachment.html>


More information about the llvm-bugs mailing list