<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 - Uninitialized bool values accessed by optimizer"
   href="https://bugs.llvm.org/show_bug.cgi?id=37766">37766</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Uninitialized bool values accessed by optimizer
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tss@iki.fi
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This happens with v3.8.0 and in 6.0.0 git version from 13 Sep 2017, so I'd
expect it to still happen with newer versions. Using valgrind shows that the
"set" variable is accessed, even though ret==false always so it's not supposed
to be accessed. Doesn't happen if foo() is in the same .c file.

/* test2.c */
#include <stdbool.h>
_Bool foo(_Bool *value_r)
{
        return false;
}

/* test.c */
#include <stdio.h>
#include <stdbool.h>

_Bool foo(_Bool *value_r);

int main(void)
{
        bool set;
        bool ret = foo(&set);
        if (ret && set)
                printf("foo\n");
        if (!ret)
                return 1;
        return 0;
}

clang test2.c -c -o test2.o
clang -O2 -g test.c test2.o -o test
valgrind ./test

==28241== Conditional jump or move depends on uninitialised value(s)
==28241==    at 0x4004E9: main (test.c:10)</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>