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

            Bug ID: 40725
           Summary: some problematic casts applied to NULL are not
                    diagnosed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: richard-l...@metafoo.co.uk
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Testcase:

#define NULL __null

int *p = reinterpret_cast<int*>(NULL); // #1
enum E {}; E e = static_cast<E>(NULL); // #2
float f = static_cast<float>(NULL); // #3

This produces no diagnostics. All marked lines should result in a warning:

 -- #1 does not necessarily produce a null pointer; it produces a pointer whose
value is all-zero-bits. We should suggest replacing reinterpret_cast with
static_cast here.
 -- #2 and #3 don't make any sense; they're using NULL as an integer rather
than as a pointer. We should suggest replacing NULL with 0 here.

Generally, we should probably warn on any use of NULL where nullptr would not
be valid or would mean something else.

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

Reply via email to