<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 negative of -Winteger-overflow"
   href="https://llvm.org/bugs/show_bug.cgi?id=22899">22899</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>false negative of -Winteger-overflow
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chengniansun@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang warns on integer overflow in variable initialization but not assignment.
For example, there is warning on 
  int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
But if I split the statement into two, Clang will not warn:
  int b; 
  b = ((uint16_t)0xE570L * (uint16_t)(-1L));


$: cat t.c
#include <stdint.h>
int main(void) {
  int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
  int b; 
  b = ((uint16_t)0xE570L * (uint16_t)(-1L));
  return 0;
}
$: clang-trunk -Wconversion t.c
t.c:3:30: warning: overflow in expression; result is -445703536 with type 'int'
      [-Winteger-overflow]
  int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
                             ^
1 warning generated.
$: gcc-trunk -Wconversion t.c
t.c: In function ‘main’:
t.c:3:30: warning: integer overflow in expression [-Woverflow]
   int a = ((uint16_t)0xE570L * (uint16_t)(-1L));
                              ^
t.c:5:26: warning: integer overflow in expression [-Woverflow]
   b = ((uint16_t)0xE570L * (uint16_t)(-1L));
                          ^
$:</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>