<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 --- - EH: clang fails on assertion on complex doubles multiplication when EH is enabled" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24196&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=fMTMSorFcbouDtF8rRBQAirW0OMhqys5sLquLj4R8oY&s=N6hgTJX2ur6JCWqUZzJAHHGXWlbld3NT3uyDhSQX358&e=">24196</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>EH: clang fails on assertion on complex doubles multiplication when EH is enabled
          </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>d.zobnin.bugzilla@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>$ cat test.cpp

struct A {
  int x;
  A() { x = 10; }
  ~A() { x = 20; }
};
int main() {
  {
    A a;
    double __complex__ d;
    double __complex__ d1 = d * d;
  }
  return 0;
}

$ clang -cc1 -fexceptions -fcxx-exceptions -O0 -emit-llvm test.cpp -o test.ll

llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X,
Y*>::ret_type llvm::cast(Y*) [with X = llvm::CallInst; Y = llvm::Instruction;
typename llvm::cast_retty<X, Y*>::ret_type = llvm::CallInst*]: Assertion
`isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Stack trace leads us to the function
ComplexExprEmitter::EmitComplexBinOpLibCall in file
llvm/tools/clang/lib/CodeGen/CGExprComplex.cpp, line:
cast<llvm::CallInst>(Call)->setCallingConv(CGF.CGM.getBuiltinCC());

This issue occurs due to EH enabling if landing pad is required at the moment
of complex numbers multiplication (Call is not actually a llvm::CallInst*, but
llvm::InvokeInst*).

I will handle this case.

Denis Zobnin
=============
Software Engineer
Intel Compiler Team
Intel</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>