[llvm-bugs] [Bug 50645] Access to uninitialized volatile stack variable generates warning

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 10 11:02:36 PDT 2021


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

vit9696 <vit9696 at avp.su> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vit9696 at avp.su
         Resolution|INVALID                     |---
             Status|RESOLVED                    |REOPENED

--- Comment #2 from vit9696 <vit9696 at avp.su> ---
The issue is legit, but the example is a bit too incomplete to properly
understand the problem. What happens inbetween the declaration and the read
operation (and was omitted from the original example) is access made via dma.
I.e. more like this:

uintptr_t get_phys_addr(volatile const void* ptr, size_t sz);
void read_data(uintptr_t addr);

bool test(void)
{
  volatile int var;
  uintptr_t phys = get_phys_addr(&var, sizeof(var));
  read_data(phys);
  return var != 0;
}

It is not correct to drop const from get_phys_addr, as we may want to get one
from a read-only object as well.

-- 
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/20210610/1acd5ca9/attachment.html>


More information about the llvm-bugs mailing list