<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 - Segfault on an ill-formed overload operator usage"
   href="https://bugs.llvm.org/show_bug.cgi?id=36831">36831</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault on an ill-formed overload operator usage
          </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>All
          </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>dmitry.kozhevnikov@jetbrains.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>On the following (ill-formed) C++ code I'm getting a segfault while parsing the
operator usage:

  struct S {
    S &operator==(...);
  };

  void foo(S s) {
    s == 1;
  }

Reproducible for me on macOS and linux, also on Compiler Explorer:
<a href="https://godbolt.org/g/QDD1d4">https://godbolt.org/g/QDD1d4</a>.

stderr from the CE on clang trunk:

<source>:2:6: error: overloaded 'operator==' must be a binary operator (has 1
parameter)
  S &operator==(...);
     ^
#0 0x0000000001fd1cfa
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x1fd1cfa)
#1 0x0000000001fcfdde
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x1fcfdde)
#2 0x0000000001fcff2c
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x1fcff2c)
#3 0x00007f7b7b34d390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x0000000003431adb
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x3431adb)
#5 0x000000000328153e
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x328153e)
#6 0x00000000032b2def
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x32b2def)
#7 0x00000000032b2fa3
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x32b2fa3)
#8 0x0000000002f4ac1c
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f4ac1c)
#9 0x0000000002f4a77c
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f4a77c)
#10 0x0000000002f4a7e9
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f4a7e9)
#11 0x0000000002f92d52
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f92d52)
#12 0x0000000002f9018f
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f9018f)
#13 0x0000000002f903ff
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f903ff)
#14 0x0000000002f95431
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f95431)
#15 0x0000000002f97d9e
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f97d9e)
#16 0x0000000002f0ab2a
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f0ab2a)
#17 0x0000000002f29f17
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f29f17)
#18 0x0000000002f054a0
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f054a0)
#19 0x0000000002f05c31
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f05c31)
#20 0x0000000002f05c6f
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f05c6f)
#21 0x0000000002f0cd78
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f0cd78)
#22 0x0000000002f0d81e
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f0d81e)
#23 0x0000000002f01403
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x2f01403)
#24 0x00000000029ced47
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x29ced47)
#25 0x000000000257186e
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x257186e)
#26 0x000000000253cfc6
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x253cfc6)
#27 0x000000000260509c
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x260509c)
#28 0x0000000000a30ec8
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0xa30ec8)
#29 0x0000000000994671
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0x994671)
#30 0x00007f7b7a2d2830 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#31 0x0000000000a2e419
(/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0+0xa2e419)
Stack dump:
0.      Program arguments:
/opt/compiler-explorer/clang-trunk-20180320/bin/clang-7.0 -cc1 -triple
x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name example.cpp -mrelocation-model static
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debug-info-kind=limited -dwarf-version=4
-debugger-tuning=gdb -coverage-notes-file
/tmp/compiler-explorer-compiler118221-63-dx4l3a.1jnn/output.gcno -resource-dir
/opt/compiler-explorer/clang-trunk-20180320/lib/clang/7.0.0 -c-isystem
/usr/include/x86_64-linux-gnu -cxx-isystem /usr/include/x86_64-linux-gnu
-internal-isystem
/opt/compiler-explorer/gcc-7.2.0/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0
-internal-isystem
/opt/compiler-explorer/gcc-7.2.0/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/x86_64-linux-gnu
-internal-isystem
/opt/compiler-explorer/gcc-7.2.0/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-trunk-20180320/lib/clang/7.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /compiler-explorer -ferror-limit 19
-fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -o
/tmp/compiler-explorer-compiler118221-63-dx4l3a.1jnn/output.s -x c++ <source> 
1.      <source>:6:9: current parser token ';'
2.      <source>:5:15: parsing function body 'foo'
3.      <source>:5:15: in compound statement ('{}')
clang-7.0: error: unable to execute command: Segmentation fault (core dumped)
clang-7.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (trunk 327957)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-trunk/bin
clang-7.0: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-7.0: note: diagnostic msg: 
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7.0: note: diagnostic msg: /tmp/example-0a6041.cpp
clang-7.0: note: diagnostic msg: /tmp/example-0a6041.sh
clang-7.0: note: diagnostic msg: 
********************
Compiler returned: 254</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>