<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 - Compiler crash for lowering c++ complex type on RISCV"
   href="https://bugs.llvm.org/show_bug.cgi?id=44904">44904</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiler crash for lowering c++ complex type on RISCV
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Testcase (from gcc testsuite g++.dg/torture/pr39678.C)
----------
struct Y {};                                                                   
                                                                               
            struct X {
  struct Y y;
  __complex__ float val;
};

struct X __attribute__((noinline))
foo (float *p)
{
  struct X x;
  __real x.val = p[0];
  __imag x.val = p[1];
  return x;
}
extern "C" void abort (void);
float a[2] = { 3., -2. };
int main()
{
  struct X x = foo(a);
  if (__real x.val != 3. || __imag x.val != -2.)
    abort ();
  return 0;
}

Execution command
----------
clang -target riscv32 -march=rv32ifd -mabi=ilp32f pr39678.C -S -O2 -o -

clang:
/fast-playground2/jim/llvm-trunk/llvm-project/clang/lib/CodeGen/TargetInfo.cpp:9502:
bool {anonymous}::RISCVABIInfo::detectFPCCEligibleStructHelper(clang::QualType, 
clang::CharUnits, llvm::Type*&, clang::CharUnits&, llvm::Type*&,
clang::CharUnits&) const: Assertion `CurOff.isZero() && "Unexpected offset for
first field"' failed.
Stack dump:
0.      Program arguments:
/fast-playground2/jim/llvm-trunk/llvm-project-build/bin/clang -target riscv32
-march=rv32ifd -mabi=ilp32f pr39678.C -S -O2 -o -
1.      pr39678.C:18:1: current parser token 'extern'
2.      pr39678.C:11:1: LLVM IR generation of declaration 'foo'
3.      pr39678.C:11:1: Generating code for declaration 'foo'
 #0 0x00000000044e72f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/fast-playground2/jim/llvm-trunk/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:0
 #1 0x00000000044e738b PrintStackTraceSignalHandler(void*)
/fast-playground2/jim/llvm-trunk/llvm-project/llvm/lib/Support/Unix/Signals.inc:625:0
 #2 0x00000000044e541c llvm::sys::RunSignalHandlers()
/fast-playground2/jim/llvm-trunk/llvm-project/llvm/lib/Support/Signals.cpp:68:0
 #3 0x00000000044e6c2e llvm::sys::CleanupOnSignal(unsigned long)
/fast-playground2/jim/llvm-trunk/llvm-project/llvm/lib/Support/Unix/Signals.inc:361:0
 #4 0x000000000441240c (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
/fast-playground2/jim/llvm-trunk/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:77:0
 #5 0x0000000004412877 CrashRecoverySignalHandler(int)
/fast-playground2/jim/llvm-trunk/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:383:0
 #6 0x00007f3e30ed8890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #7 0x00007f3e2ff22e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #8 0x00007f3e2ff24801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #9 0x00007f3e2ff1439a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
#10 0x00007f3e2ff14412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
#11 0x0000000004a0f474 (anonymous
namespace)::RISCVABIInfo::detectFPCCEligibleStructHelper(clang::QualType,
clang::CharUnits, llvm::Type*&, clang::CharUnits&, llvm::Type*&,
 clang::CharUnits&) const
/fast-playground2/jim/llvm-trunk/llvm-project/clang/lib/CodeGen/TargetInfo.cpp:9502:0 
...

Thanks.
Jim.</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>