<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 - Missing diagnostics about unsequenced modifications and unintentional assignments"
   href="https://bugs.llvm.org/show_bug.cgi?id=34363">34363</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing diagnostics about unsequenced modifications and unintentional assignments
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hans@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Some interesting cases from a Chromium bug report:
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=760070">https://bugs.chromium.org/p/chromium/issues/detail?id=760070</a>

$ cat /tmp/a.cc
void f(int x, int y) {
  bool b = (x == y) ? 42 : b = 43;
  bool c = c = y == 42;
}


$ bin/clang -c -Weverything /tmp/a.cc
/tmp/a.cc:1:6: warning: no previous prototype for function 'f'
[-Wmissing-prototypes]
void f(int x, int y) {
     ^
1 warning generated.


$ gcc -c -Wall /tmp/a.cc
/tmp/a.cc: In function ‘void f(int, int)’:
/tmp/a.cc:2:32: warning: operation on ‘b’ may be undefined [-Wsequence-point]
   bool b = (x == y) ? 42 : b = 43;
                                ^
/tmp/a.cc:4:21: warning: operation on ‘c’ may be undefined [-Wsequence-point]
   bool c = c = y == 42;
                     ^



Sequence points aside, perhaps it would make sense to warn (and suggest
parenthesis) about the right-hand side assignment like we do in if-statements?

$ cat /tmp/a.cc
bool f(int x, int y) {
  bool b = x = y;
  return b;
}
$ bin/clang -c -Weverything /tmp/a.cc
/tmp/a.cc:1:6: warning: no previous prototype for function 'f'
[-Wmissing-prototypes]
bool f(int x, int y) {
     ^
1 warning generated.</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>