[LLVMbugs] [Bug 16356] New: detect null dereference in rvalue

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 17 17:02:46 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16356

            Bug ID: 16356
           Summary: detect null dereference in rvalue
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Awesome:

$ echo 'void f() { *((char*)(0)) = 0; }' | clang -x c++ -
<stdin>:1:12: warning: indirection of non-volatile null pointer will be
deleted,
      not trap [-Wnull-dereference]
void f() { *((char*)(0)) = 0; }
           ^~~~~~~~~~~~~
<stdin>:1:12: note: consider using __builtin_trap() or qualifying pointer with
      'volatile'

Not as awesome:

$ echo 'void f() { *((char*)(0)); }' | clang -x c++ -
<stdin>:1:12: warning: expression result unused [-Wunused-value]
void f() { *((char*)(0)); }
           ^~~~~~~~~~~~~
1 warning generated.

We point out that something's wrong here, but a user who writes this isn't
going to understand that it means "we will not trap here". Saying "expression
discarded" instead of "expression result unused" would probably be enough to
coax the user into writing the code which generates the first diagnostic.

(See also related bug 11876, if we were more aggressive about this, it would
probably catch that case too.)

-- 
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/20130618/5f9a887d/attachment.html>


More information about the llvm-bugs mailing list