[llvm-bugs] [Bug 50863] New: miscompile with templated coroutine

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 25 04:14:48 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50863

            Bug ID: 50863
           Summary: miscompile with templated coroutine
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bhalevy at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

The following program miscompiles, https://godbolt.org/z/9nPze58xj

// Coroutine miscompile reproducer.
//
// clang version 12.0.0
// Target: x86_64-unknown-linux-gnu
//
// Compile with `clang++ -std=c++20 -stdlib=libc++ -fsanitize=undefined -O0`.

#include <experimental/coroutine>

struct task{
  struct promise_type {
    task get_return_object() { return {}; }
    std::experimental::suspend_never initial_suspend() { return {}; }
    std::experimental::suspend_never final_suspend() noexcept { return {}; }
    void return_void() {}
    void unhandled_exception() {}
  };
};

namespace std::experimental {
    template <typename ...Args>
    struct coroutine_traits<task, Args...> {
        using promise_type = typename task::promise_type;
    };
}

template <typename T>
task foo(T) noexcept {
    co_return;
}

int main() {
    foo(0);
}

Compiler output:
ASM generation compiler returned: 0
error: Cannot represent a difference across sections
error: Cannot represent a difference across sections
error: Cannot represent a difference across sections
3 errors generated.
Execution build compiler returned: 1

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210625/635b8d9a/attachment.html>


More information about the llvm-bugs mailing list