<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 - clang-format damages "alternative representations" for operators"
   href="https://bugs.llvm.org/show_bug.cgi?id=43531">43531</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format damages "alternative representations" for operators
          </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>Windows NT
          </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>Formatter
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sfinae@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>compl 5 means ~5. When clang-format sees this, it's so eager to smash away the
space, that it emits compl5 which damages the code.

C:\Temp>type woof.cpp
#include <ciso646>
#include <cstdio>

int main()
{
    unsigned int x = 7;
    x &= ~5;
    printf("Should be 2: %u\n", x);

    unsigned int y = 7;
    y and_eq compl 5;
    printf("Should be 2: %u\n", y);
}

C:\Temp>cl /EHsc /nologo /W4 woof.cpp && woof
woof.cpp
Should be 2: 2
Should be 2: 2

C:\Temp>clang-cl -m64 /EHsc /nologo /W4 woof.cpp && woof
Should be 2: 2
Should be 2: 2

C:\Temp>clang-format -i woof.cpp

C:\Temp>type woof.cpp
#include <ciso646>
#include <cstdio>

int main() {
  unsigned int x = 7;
  x &= ~5;
  printf("Should be 2: %u\n", x);

  unsigned int y = 7;
  y and_eq compl5;
  printf("Should be 2: %u\n", y);
}

C:\Temp>cl /EHsc /nologo /W4 woof.cpp && woof
woof.cpp
woof.cpp(10): error C2065: 'compl5': undeclared identifier

C:\Temp>clang-cl -m64 /EHsc /nologo /W4 woof.cpp && woof
woof.cpp(10,12): error: use of undeclared identifier 'compl5'
  y and_eq compl5;
           ^
1 error generated.

C:\Temp>clang-format -version
clang-format version 8.0.1 (tags/RELEASE_801/final)</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>