<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] ASan reports stack-use-after-scope when coroutine allocation is elided"
   href="https://bugs.llvm.org/show_bug.cgi?id=47767">47767</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[coroutines] ASan reports stack-use-after-scope when coroutine allocation is elided
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>erik@olofsson.info
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This happens when the coroutine frame allocation is elided and the promise
constructor is not inlined. See: <a href="https://godbolt.org/z/8EzP7a">https://godbolt.org/z/8EzP7a</a>

// -std=c++20 -stdlib=libc++ -O3 -g -fcoroutines-ts -fsanitize=address
-fsanitize-address-use-after-scope


#include <experimental/coroutine>

#define inline_never __attribute__((noinline)) 
#define inline_always inline __attribute__((always_inline))

template <typename T>
class co;

using suspend_never = std::experimental::suspend_never;

template <typename T>
class promise;

template <>
struct promise <void> 
{
    int member = 0;
    inline_never promise() 
    {
    }

    ~promise() 
    {
    }

    co<void> get_return_object() noexcept;

    void return_void() noexcept 
    {
    };

    suspend_never initial_suspend() noexcept 
    {
        return {};
    }

    void unhandled_exception() noexcept 
    {
    }

    suspend_never final_suspend() noexcept 
    {
        return {};
    }
};

template <typename T = void>
struct co 
{
    using promise_type = promise<T>;
    ~co() 
    {
    }
};

inline_always co<void> promise<void>::get_return_object() noexcept {
    return co<void>();
}

inline_never co<> bar() {
    co_return;
}

int main() {
    bar();
    return 0;
}</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>