<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - False positive, 32-bit access from a 64-bit initialized value"
   href="https://bugs.llvm.org/show_bug.cgi?id=47727">47727</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>False positive, 32-bit access from a 64-bit initialized value
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>eblot.ml@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Using LLVM/clang 11.0.0-rc3 static analyzer.

The following snippets should, I believe, run ok with the static analyzer.

void foo1(uint32_t * out) {
    uint64_t tmp64;
    tmp64 = 0;

    uint32_t * tmp32 = (uint32_t *)&tmp64;
    *out = tmp32[1];
}

void foo2(uint32_t * out) {
    uint64_t tmp64[1];
    tmp64[0] = 0;

    uint32_t * tmp32 = (uint32_t *)tmp64;
    *out = tmp32[1];
}

void foo3(uint32_t * out) {
    uint64_t tmp64[1];
    memset(tmp64, 0, sizeof(tmp64));

    uint32_t * tmp32 = (uint32_t *)tmp64;
    *out = tmp32[1];
}

However, `foo2` is signalled with 

warning: Assigned value is garbage or undefined
    *out = tmp32[1];
         ^ ~~~~~~~~
1 warning generated.

On 32-bit target, both upper and lower 32-bit location of tmp64 are initialized
to 0, so these locations do not contain garbage.

They all generate the same ASM code (RISC-V 32 bit target, -O0)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>