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

            Bug ID: 33459
           Summary: p static_cast<int16_t>(...) has inconsistent output
           Product: lldb
           Version: 3.9
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev@lists.llvm.org
          Reporter: vi...@nethacker.com
                CC: llvm-b...@lists.llvm.org

(lldb) version
lldb version 3.9.0 ( revision )

(lldb) p r_sigma_float
(const float) $11 = 0.0500000007

(correct)

(lldb) p (1.0f / (2 * r_sigma_float * r_sigma_float)) * (1<<kQ)
(float) $3 = 51199.9961

(correct)

(lldb) p static_cast<int16_t>(51199.99f)
(int16_t) $1 = 32767

Technically, this is undefined but the output here matches what g++ does so I
think it's good.  Clang current returns inconsistent results.  Ideally, it
would be nice for lldb to print (undefined) or be consistent with whatever
compiler you are using.  I'm hoping to get clang's behavior changed:
https://bugs.llvm.org/show_bug.cgi?id=33448
http://eel.is/c++draft/conv.fpint#1

(lldb) p static_cast<int16_t>((1.0f / (2 * r_sigma_float * r_sigma_float)) *
(1<<kQ))
(int16_t) $2 = -14337

Again this is undefined but it is inconsistent with the previous behavior so I
would call it a bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to