Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation issue: no member named 'construct' #1611

Closed
hsdk123 opened this issue Jun 19, 2024 · 4 comments
Closed

compilation issue: no member named 'construct' #1611

hsdk123 opened this issue Jun 19, 2024 · 4 comments

Comments

@hsdk123
Copy link

hsdk123 commented Jun 19, 2024

Hi, I'm seeing a new error in compilation:

In file included from D:/a/Light.vn-core/Light.vn-core/_deps/sol2/80081c33f3d3c0bc53deb21b682463e1ae98eef5/include\sol/sol.hpp:53:
In file included from D:/a/Light.vn-core/Light.vn-core/_deps/sol2/80081c33f3d3c0bc53deb21b682463e1ae98eef5/include\sol/stack.hpp:27:
In file included from D:/a/Light.vn-core/Light.vn-core/_deps/sol2/80081c33f3d3c0bc53deb21b682463e1ae98eef5/include\sol/trampoline.hpp:27:
In file included from D:/a/Light.vn-core/Light.vn-core/_deps/sol2/80081c33f3d3c0bc53deb21b682463e1ae98eef5/include\sol/types.hpp:28:
In file included from D:/a/Light.vn-core/Light.vn-core/_deps/sol2/80081c33f3d3c0bc53deb21b682463e1ae98eef5/include\sol/optional.hpp:33:

D:/a/Light.vn-core/Light.vn-core/_deps/sol2/80081c33f3d3c0bc53deb21b682463e1ae98eef5/include\sol/optional_implementation.hpp:2191:10: error: no member named 'construct' in 'optional<type-parameter-0-0 &>'

 2191 |                         this->construct(std::forward<Args>(args)...);

      |                         ~~~~  ^

1 error generated.

compiler: CMAKE_C_COMPILER: D:/a/Light.vn-core/Light.vn-core/emsdk/upstream/emscripten/emcc.bat

-- The CXX compiler identification is Clang 19.0.0
-- The C compiler identification is Clang 19.0.0
@tukss
Copy link

tukss commented Jul 10, 2024

I'm getting the same error. Even a simple test program that just includes sol/sol.hpp fails with the same error on Clang 19 (current main) but compiles fine with version 18.1.6.

It boils down to the implementation of the emplace member function in class optional.

template <class... Args>

At first glance it's strange why this ever worked. The construct member function is not part of optional.

Some further tests show that clang < 19 doesn't actually test for the existence of the member functions being called inside another member function of a templated type. Clang 19 changed that. This example might be instructive:

template<int i>
struct bar {
  void baz() {
    this->foo();
  }
};

int main(int argc, char**argv){

  bar<1> a;

  // uncommenting the code below makes it fail on every compiler
  // On clang >= 19 it even fails without the explicit call to baz but it works on g++ and clang < 19.
  //a.baz();

  return 0;
}

So I think this just worked before because emplace wasn't actually used. For my application I could get everything to work by just removing emplace entirely.

As a side note: The return type of emplace is T& but we don't actually return anything. This should probably be fixed as well.

@tukss
Copy link

tukss commented Jul 10, 2024

#1606 fixes it for me.

It seems that this-> doesn't resolve to m_value as it's suggested by operator overloading.

@hsdk123
Copy link
Author

hsdk123 commented Jul 11, 2024

Thanks @tukss! Hope the fix gets into main

@hsdk123 hsdk123 mentioned this issue Jul 12, 2024
@hsdk123
Copy link
Author

hsdk123 commented Jul 16, 2024

1606 merged - confirming issue resolved!
Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants