<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 - coroutines + templates + "-fsanitize=undefined" = error in backend: Cannot represent a difference across sections (clang++ 10, 11, 12, trunk)"
   href="https://bugs.llvm.org/show_bug.cgi?id=50345">50345</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>coroutines + templates + "-fsanitize=undefined" = error in backend: Cannot represent a difference across sections (clang++ 10, 11, 12, trunk)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24858" name="attach_24858" title="Code that crashes the compiler">attachment 24858</a> <a href="attachment.cgi?id=24858&action=edit" title="Code that crashes the compiler">[details]</a></span>
Code that crashes the compiler

The attached file causes clang++ to crash given certain compilation flags.
also godbolt: <a href="https://godbolt.org/z/j14YMxj5M">https://godbolt.org/z/j14YMxj5M</a>

$ clang++ --version
    clang version 10.0.1 (Fedora 10.0.1-3.fc32)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
$ clang++ coro-crash.cpp -std=c++20 -stdlib=libc++ -fsanitize=undefined
    fatal error: error in backend: Cannot represent a difference across
sections
    Stack dump:
    0.  Program arguments: /usr/bin/clang++ -std=c++20 -fsanitize=undefined
-fcolor-diagnostics -stdlib=libc++ -c -o coro-crash.o coro-crash.cpp 
    1.  <eof> parser at end of file
    2.  Code generation
   
/lib64/libLLVM-10.so(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x2e)[0x7f60b555e10e]
   
/lib64/libLLVM-10.so(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x7f60b555c3e4]
   
/lib64/libLLVM-10.so(_ZN4llvm20CrashRecoveryContext10HandleExitEi+0x78)[0x7f60b549b768]
    /lib64/libLLVM-10.so(_ZN4llvm3sys7Process4ExitEi+0x1b)[0x7f60b5556ffb]
    /usr/bin/clang++(+0x16372)[0x55988c5f0372]
   
/lib64/libLLVM-10.so(_ZN4llvm18report_fatal_errorERKNS_5TwineEb+0x8b)[0x7f60b54a702b]
    /lib64/libLLVM-10.so(+0x1bc7623)[0x7f60b66db623]
    /lib64/libLLVM-10.so(+0x1ba83c6)[0x7f60b66bc3c6]
   
/lib64/libLLVM-10.so(_ZN4llvm11MCAssembler11handleFixupERKNS_11MCAsmLayoutERNS_10MCFragmentERKNS_7MCFixupE+0xf2)[0x7f60b66d2ed2]
   
/lib64/libLLVM-10.so(_ZN4llvm11MCAssembler6layoutERNS_11MCAsmLayoutE+0x281)[0x7f60b66d40b1]
    /lib64/libLLVM-10.so(_ZN4llvm11MCAssembler6FinishEv+0x3d)[0x7f60b66d42ad]
   
/lib64/libLLVM-10.so(_ZN4llvm10AsmPrinter14doFinalizationERNS_6ModuleE+0x731)[0x7f60b5c64b11]
   
/lib64/libLLVM-10.so(_ZN4llvm13FPPassManager14doFinalizationERNS_6ModuleE+0x65)[0x7f60b5658895]
   
/lib64/libLLVM-10.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x460)[0x7f60b5664220]
    /lib64/libclang-cpp.so.10(+0x16123e1)[0x7f60baea73e1]
   
/lib64/libclang-cpp.so.10(_ZN5clang17EmitBackendOutputERNS_17DiagnosticsEngineERKNS_19HeaderSearchOptionsERKNS_14CodeGenOptionsERKNS_13TargetOptionsERKNS_11LangOptionsERKN4llvm10DataLayoutEPNSE_6ModuleENS_13BackendActionESt10unique_ptrINSE_17raw_pwrite_streamESt14default_deleteISM_EE+0x2fe)[0x7f60baea805e]
    /lib64/libclang-cpp.so.10(+0x190fb39)[0x7f60bb1a4b39]
   
/lib64/libclang-cpp.so.10(_ZN5clang8ParseASTERNS_4SemaEbb+0x499)[0x7f60ba208c09]
   
/lib64/libclang-cpp.so.10(_ZN5clang14FrontendAction7ExecuteEv+0xb9)[0x7f60bb83c139]
   
/lib64/libclang-cpp.so.10(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x1cd)[0x7f60bb7f827d]
   
/lib64/libclang-cpp.so.10(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x95c)[0x7f60bb8b212c]
   
/usr/bin/clang++(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x6c0)[0x55988c5f1440]
    /usr/bin/clang++(+0x15a94)[0x55988c5efa94]
    /lib64/libclang-cpp.so.10(+0x1c8cec9)[0x7f60bb521ec9]
   
/lib64/libLLVM-10.so(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0x27)[0x7f60b549b5e7]
   
/lib64/libclang-cpp.so.10(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x157)[0x7f60bb524537]
   
/lib64/libclang-cpp.so.10(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x9d)[0x7f60bb4f8bed]
   
/lib64/libclang-cpp.so.10(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x86)[0x7f60bb4f9156]
   
/lib64/libclang-cpp.so.10(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x93)[0x7f60bb501693]
    /usr/bin/clang++(main+0x14a6)[0x55988c5ebb86]
    /lib64/libc.so.6(__libc_start_main+0xf2)[0x7f60b4766042]
    /usr/bin/clang++(_start+0x2e)[0x55988c5ecc1e]

also checked through godbolt: crashes in clang 11 and clang trunk, clang 12
doesn't crash but prints errors.

None of these commands crash:
    clang++ coro-crash.cpp -std=c++20 -stdlib=libc++ -fsanitize=undefined
-emit-llvm -Xclang -disable-llvm-passes -c
    clang++ coro-crash.cpp -std=c++20 -stdlib=libc++ -fsanitize=undefined
-emit-llvm -Xclang -c

by <a href="https://llvm.org/docs/HowToSubmitABug.html#crashing-bugs">https://llvm.org/docs/HowToSubmitABug.html#crashing-bugs</a> I deduced that it's
a backend bug (as if it wasn't obvious by the error message and the "Code
generation" part in the dump).

However, after generating coro_crash.bc using:
    clang++ coro-crash.cpp -std=c++20 -stdlib=libc++ -fsanitize=undefined
-emit-llvm -c -o coro_crash.bc
none of these commands crash either:
    llc coro_crash.bc
    llc coro_crash.bc -relocation-model=pic
    llc coro_crash.bc -relocation-model=static
Hence <a href="https://llvm.org/docs/HowToSubmitABug.html#backend-code-generator-bugs">https://llvm.org/docs/HowToSubmitABug.html#backend-code-generator-bugs</a>
claims that I should follow instructions for front-end bugs, but every other
evidence points to a backend bug, so dunno. Maybe it's a mix of bugs,
frontent/middle passing incorrect input to backend or whatever.

Anyway, bugpoint doesn't want to cooperate with me either:
    bugpoint -run-llc coro_crash.bc
    Read input file      : 'coro_crash.bc'
    *** All input ok
    Initializing execution environment: Found llc: /usr/bin/llc
    Sorry, I can't automatically select a safe interpreter!

    Exiting.

So I guess that's all what I can give in this bug report.</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>