[LLVMbugs] [Bug 9200] New: Zero-length VLA test doesn't do adequate range propagation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Feb 11 04:23:12 PST 2011


           Summary: Zero-length VLA test doesn't do adequate range
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: csdavec at swan.ac.uk
                CC: llvmbugs at cs.uiuc.edu

The analyser is reporting incorrectly in this instance

2092       if (ptr == end)
3 Taking false branch

2093        {
2094          return 0;
2095        }
2096      else
2097        {
2098          unsigned    len = (end - ptr) < 32 ? (end - ptr) : 31;
4 '?' condition is true

2099          char    buf[len+1];
5 Declared variable-length array (VLA) has zero size

>From line 2092, it knows that ptr != end, therefore ptr - end is not 0.  On
line 2098, it is taking the condition as true, therefore end - ptr < 32.  This
means that end-ptr is guaranteed to be in the range 1-31.  Therefore, the size
of the VLA is 2-32.  

Note that even without the original case being propagated, the condition tells
us that len is in the range 0-31, therefore len + 1 can not be 0.

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