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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to