[llvm-bugs] [Bug 38963] New: Warn when dereferencing pointer immediatelly after allocation using malloc

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 15 23:23:26 PDT 2018


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

            Bug ID: 38963
           Summary: Warn when dereferencing pointer immediatelly after
                    allocation using malloc
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

void x(void) {
    int *p = (int *)malloc(sizeof(int));
    if (*p)
        abort();
}


LLVM seems to optimize it to just abort() - that's fine. 

But we should warn under -Wuninitialized. Currently, there is no warning when
compiling with -Wall.

+ realloc? aligned_alloc?

-- 
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/20180916/04f73aaf/attachment-0001.html>


More information about the llvm-bugs mailing list