Comments (3)
Just now, found out that compiling with clang also has this error.
from sol2.
This is the error (godbolt)
In file included from <source>:4:
In file included from /opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/sol.hpp:54:
In file included from /opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype.hpp:27:
In file included from /opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_core.hpp:37:
In file included from /opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container_launch.hpp:28:
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container.hpp:541:12: error: non-const lvalue reference to type 'span<...>' cannot bind to a temporary of type 'span<...>'
541 | return stack::unqualified_get<T>(L, 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container.hpp:1212:17: note: in instantiation of member function 'sol::container_detail::usertype_container_default<std::span<std::basic_string<char>>>::get_src' requested here
1212 | auto& src = get_src(L);
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container.hpp:1353:12: note: in instantiation of function template specialization 'sol::container_detail::usertype_container_default<std::span<std::basic_string<char>>>::pairs_associative<false>' requested here
1353 | return pairs_associative<false>(is_assoc(), L);
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container_launch.hpp:125:16: note: in instantiation of member function 'sol::container_detail::usertype_container_default<std::span<std::basic_string<char>>>::pairs' requested here
125 | return uc::pairs(L);
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container_launch.hpp:133:12: note: in instantiation of member function 'sol::container_detail::u_c_launch<std::span<std::basic_string<char>>>::real_pairs_traits' requested here
133 | return real_pairs_traits(container_detail::has_traits_pairs<uc>(), L);
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container_launch.hpp:286:74: note: in instantiation of member function 'sol::container_detail::u_c_launch<std::span<std::basic_string<char>>>::real_pairs_call' requested here
286 | return detail::typed_static_trampoline<decltype(&real_pairs_call), (&real_pairs_call)>(L);
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/usertype_container_launch.hpp:335:46: note: (skipping 8 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
335 | { "__pairs", &meta_usertype_container::pairs_call },
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/stack_core.hpp:948:19: note: in instantiation of function template specialization 'sol::stack::push<sol::detail::as_reference_tag, std::span<std::basic_string<char>> &, void>' requested here
948 | return stack::push<Tr>(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/stack_core.hpp:955:25: note: in instantiation of function template specialization 'sol::stack::stack_detail::push_reference<std::span<std::basic_string<char>> &, std::span<std::basic_string<char>> &>' requested here
955 | return stack_detail::push_reference<T>(L, std::forward<T>(t), std::forward<Args>(args)...);
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/stack_core.hpp:982:20: note: in instantiation of function template specialization 'sol::stack::push_reference<std::span<std::basic_string<char>> &>' requested here
982 | int pushcount = push_reference(L, std::forward<T>(t));
| ^
/opt/compiler-explorer/libs/sol2/v3.2.1/include/sol/unsafe_function.hpp:169:27: note: in instantiation of function template specialization 'sol::stack::multi_push_reference<std::span<std::basic_string<char>> &>' requested here
169 | int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
| ^
<source>:21:4: note: in instantiation of function template specialization 'sol::basic_function<sol::basic_reference<false>, false>::operator()<std::span<std::basic_string<char>> &>' requested here
21 | f1(sp);// compile error
| ^
3 warnings and 1 error generated.
Looks like the issue is here
sol2/include/sol/usertype_container.hpp
Line 557 in e8e122e
The function returns auto&
, but when #define SOL_SAFE_USERTYPE 0
is set, stack::unqualified_get<T>(L_, 1);
is returned. Changing it to stack::unqualified_get<T&>(L_, 1);
probably fixes the issue, as it is similar to the code when the setting is on.
from sol2.
@Rochet2
You inspired me to try your program.
But it still doesn't pass compilation and I used instead:
return *stack::unqualified_get<T*>(L_, 1);
It works.
from sol2.
Related Issues (20)
- Missing documentation for using Sol to write Lua C libraries HOT 2
- Panic with multiple states HOT 1
- Segfault from protected_function args push HOT 2
- std::terminate called on attempting to index a nil value HOT 2
- Doesn't build with Clang 18.1.0 HOT 9
- Not able to build with CMake HOT 3
- How to pass Lua Closures into C++ Functions in Sol3 ? HOT 4
- Test failure on x86
- Custom module loaders not working? HOT 1
- A const C++ container can be modified in Lua (want it to be truly const)
- Compilation Error when Member Variables set in new_usertype. HOT 1
- A bunch of errors when using usertypes HOT 1
- Is it possible to have out params / replace type and data referenced by sol::object? HOT 2
- Passing nil as userdata to C++ to reset a variable HOT 3
- On MSVC std::filesystem::path cannot be used as Lua type HOT 1
- Crash during destruction when using meta_function::new_index and coroutines
- Accessing table field with the wrong user type causes a segmentation fault
- Cannot directly bind b2Vec2 to a table entry
- SOL_BASE_CLASSES / SOL_DERIVED_CLASSES should be mentioned in the documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sol2.