Naios / continuable

C++14 asynchronous allocation aware futures (supporting then, exception handling, coroutines and connections)
https://naios.github.io/continuable/
MIT License
815 stars 44 forks source link

compile error with clang 14 #59

Closed Spongman closed 1 year ago

Spongman commented 1 year ago

@Naios

I have been using gcc10 on centos7, and that has been working fine, but i just tried clang on ubuntu, and i'm getting this error:

$ cat test.cpp
#include <coroutine>
#include <continuable/continuable.hpp>

cti::continuable<int> foo()
{
        co_return 3;
}

$ clang++ --version
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ clang++ -I. -std=c++20 -c test.cpp
test.cpp:4:23: error: this function cannot be a coroutine: 'std::coroutine_traits<cti::continuable_base<cti::detail::erasure::continuation<int>, cti::detail::identity<int>>>' has no member named 'promise_type'
cti::continuable<int> foo()
                      ^
1 error generated.

I tried both libstdc++ & libc++, same error.

I also found it odd that I needed to explicitly include <coroutine>...


master

Your Environment

Naios commented 1 year ago

Thanks for your report, can you check whether coroutine support is detected in https://github.com/Naios/continuable/blob/master/include/continuable/detail/features.hpp ? Is it possible that clang 14 still might require a compiler flag to enable coroutines?

Spongman commented 1 year ago

i don't think that's it. here is latest master failing with clang 15: https://gcc.godbolt.org/z/ThcnbMKK5

<source>:16:23: error: this function cannot be a coroutine: 'std::coroutine_traits<cti::continuable_base<cti::detail::erasure::continuation<int>, cti::detail::identity<int>>>' has no member named 'promise_type'
Spongman commented 1 year ago

ah. i take it back, it looks like the clang detection is wrong.

  #elif defined(__clang__) // Clang
    #if defined(__cpp_coroutines) && (__cpp_coroutines >= 201707)
      #define CONTINUABLE_HAS_COROUTINE 1
      #define CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE 1
    #endif // defined(__cpp_coroutines) && (__cpp_coroutines >= 201707)

clang master reports 201703L.