[LLVMbugs] [Bug 8183] "indirection of non-volatile null pointer" warning in dead code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 22 21:12:48 PST 2011


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

Ted Kremenek <kremenek at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #17 from Ted Kremenek <kremenek at apple.com> 2011-02-22 23:12:48 CST ---
(In reply to comment #16)
> (In reply to comment #15)
> > This warning is now suppressed for the trivial 'if' and '?:' cases where basic
> > reachability analysis on the CFG can prune can determine the code is dead:
> > 
> >   http://llvm.org/viewvc/llvm-project?view=rev&revision=126290
> > 
> > This should handle Jed's case.
> > 
> > This case is still not handled:
> > 
> >     #define U64Divide(dividend, divisor, remainder) (( (void)((remainder) &&
> > (*((UInt64*)(remainder)) = ((UInt64)(dividend) % (UInt64)(divisor)))),
> > ((UInt64)(dividend) / (UInt64)(divisor)) ))
> > 
> > This requires further finessing of the CFG for '&&'.
> 
> This issue remains because the CFG is not pruning the true branch in the case
> of a void* null pointer for the condition.  Here is a reduced test case:
> 
> $ cat test.m
> typedef unsigned long long UInt64;
> 
> void foo(UInt64 test)
> {
>   (void)((((void*)0)) && (*((UInt64*)(((void*)0))) = ((UInt64)((test)) %
> (UInt64)((1000000000)))));
> }
> 
> $ clang -fsyntax-only test.m
> 
> test.m:5:27: warning: indirection of non-volatile null pointer will be deleted,
> not trap
>   (void)((((void*)0)) && (*((UInt64*)(((void*)0))) = ((UInt64)((test)) %
> (UInt64)((1000000000)))));
>                           ^~~~~~~~~~~~~~~~~~~~~~~~
> /tmp/test.m:5:27: note: consider using __builtin_trap() or qualifying pointer
> with 'volatile'
> 
> 
> and the CFG:
> 
> 
>  [ B4 (ENTRY) ]
>     Predecessors (0):
>     Successors (1): B2
> 
>  [ B1 ]
>       1: (([B2.1])) && ([B3.1])
>       2: (void)([B1.1])
>     Predecessors (2): B3 B2
>     Successors (1): B0
> 
>  [ B2 ]
>       1: (void *)0
>       T: (([B2.1])) && ...
>     Predecessors (1): B4
>     Successors (2): B3 B1
> 
>  [ B3 ]
>       1: *((UInt64 *)(((void *)0))) = ((UInt64)((test)) %
> (UInt64)((1000000000)))
>     Predecessors (1): B2
>     Successors (1): B1
> 
>  [ B0 (EXIT) ]
>     Predecessors (1): B1
>     Successors (0):
> 
> Note that the CFG does prune branches for '&&'; for some reason it isn't
> working with the void*.

This case is now handled:

  r126305

Clang no longer reports warnings for HowLongTimer.m.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list