#<field> is not a member of <class> but is

41 messages · Page 1 of 1 (latest)

pearl frigate
#

Hello, does anyone have an idea why Clang thinks that _promise is not a member of the Awaiter class:

template <typename T>
struct _Task {
    // ...
    struct promise_type {
        // ...
        auto final_suspend() noexcept {
            struct Awaiter {
                promise_type *_promise;

                void await_suspend(std::coroutine_handle<void>) noexcept {
                    auto cfp = std::exchange(_promise->_cfp, Cfp::PAST_SUSPEND);
                    if (cfp == Cfp::PAST_START)
                        _promise->_resume->resume();
                }
    // ...

Compilation command & output:

clang++ -c -o .cutekit/build/efi-x86_64-2f159776/karm-base-tests/__obj__/test-async.cpp.o src/libs/karm-base/tests/test-async.cpp -MD -MF .cutekit/build/efi-x86_64-2f159776/karm-base-tests/__obj__/test-async.cpp.o.d -std=gnu++2b -Wall -Wextra -Werror -fcolor-diagnostics -fno-exceptions -fno-rtti -target x86_64-unknown-windows -ffreestanding -fno-stack-protector -fshort-wchar -mno-red-zone -I.cutekit/extern/cute-engineering -I.cutekit/extern/cute-engineering/ce-libc/src/ce-libc -I.cutekit/extern/cute-engineering/ce-libm/src/ce-libm -I.cutekit/extern/cute-engineering/ce-stdcpp/src/ce-stdcpp -Isrc/apps -Isrc/assets -Isrc/impls -Isrc/kernel -Isrc/libs -Isrc/specs -Isrc/web -D__ck_abi_ms__ -D__ck_abi_value=ms -D__ck_arch_value=x86_64 -D__ck_arch_x86_64__ -D__ck_karm_sys_encoding_utf16__ -D__ck_karm_sys_encoding_value=utf16 -D__ck_karm_sys_line_ending_crlf__ -D__ck_karm_sys_line_ending_value=crlf -D__ck_karm_sys_path_separator_backslash__ -D__ck_karm_sys_path_separator_value=backslash -D__ck_sys_efi__ -D__ck_sys_value=efi -D__ck_toolchain_clang__ -D__ck_toolchain_value=clang -D__ck_version_'24_01'__ -D__ck_version_value='24.01'
In file included from src/libs/karm-base/tests/test-async.cpp:1:
src/libs/karm-base/async.h:358:46: error: 'Karm::Async::_Task<int>::promise_type::final_suspend()::Awaiter::await_suspend(std::coroutine_handle<void>)::Awaiter::_promise' is not a member of class 'Awaiter'
                    auto cfp = std::exchange(_promise->_cfp, Cfp::PAST_SUSPEND);
                                             ^
src/libs/karm-base/async.h:350:20: note: in instantiation of member function 'Karm::Async::_Task<int>::promise_type::final_suspend()::Awaiter::await_suspend' requested here
            struct Awaiter {
                   ^
src/libs/karm-base/async.h:360:25: error: 'Karm::Async::_Task<int>::promise_type::final_suspend()::Awaiter::await_suspend(std::coroutine_handle<void>)::Awaiter::_promise' is not a member of class 'Awaiter'
                        _promise->_resume->resume();
                        ^
2 errors generated.

Full context:

https://github.com/skift-org/skift/blob/main/src/libs/karm-base/async.h#L358

chilly tangleBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

tacit frost
pearl frigate
tacit frost
#

show the build log

pearl frigate
#
In file included from src/libs/karm-base/tests/test-async.cpp:1:
src/libs/karm-base/async.h:358:55: error: 'Karm::Async::_Task<int>::promise_type::final_suspend()::Awaiter::await_suspend(std::coroutine_handle<void>)::Awaiter::_promise' is not a member of class 'Awaiter'
                    auto cfp = std::exchange(Awaiter::_promise->_cfp, Cfp::PAST_SUSPEND);
                                             ~~~~~~~~~^
src/libs/karm-base/async.h:350:20: note: in instantiation of member function 'Karm::Async::_Task<int>::promise_type::final_suspend()::Awaiter::await_suspend' requested here
            struct Awaiter {
                   ^
src/libs/karm-base/async.h:360:34: error: 'Karm::Async::_Task<int>::promise_type::final_suspend()::Awaiter::await_suspend(std::coroutine_handle<void>)::Awaiter::_promise' is not a member of class 'Awaiter'
                        Awaiter::_promise->_resume->resume();
                        ~~~~~~~~~^
2 errors generated.
tacit frost
#

the className::fieldName syntax is meant for inheritance field name duplicates, so just use the this and you should be good to go

#

so, to make the full class name work...

#

one moment...

#

::Karm::Async::_Task<T>::promise_type::final_suspend()::Awaiter::_prom
this shit?

#

hahaha

pearl frigate
tacit frost
tacit frost
#

oh yeah, local classes' type cannot be accessed, no matter how hard you try, only nested classes' type can be accessed.

tacit frost
#

@pearl frigate


template<typename T>
struct Sample
{
    int num;

    struct Nested
    {
        void func()
        {
            struct Dummy
            {
                int x;
            
                int f1()
                {
                    return Dummy::x;
                }

                int f2() { return this->x; }

                int f3() { return x; }
            };
        }
    };
};

int main()
{
    
}

this compiles, so why your build doesn't accept all the options is questionable

pearl frigate
tacit frost
#

lmfao

pearl frigate
#

or the template at the top level

tacit frost
#

marvelous

#

AND USELESS

tacit frost
pearl frigate
chilly tangleBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

tacit frost
#

why is clang doing this?

pearl frigate
tacit frost
#

hahahahahahaha, emulating MSVC bugs in the name of ABI compatibility, meme of the month

#

🎉 🎉 🎉