Skip to content

Commit

Permalink
Fix build with Clang 19 - take 2 (#26)
Browse files Browse the repository at this point in the history
* 3rdparty/sol2: Fixed build with clang 19.

sol::optional<T&>::emplace was broken, and depended on the compiler not
checking that members exist if the template wasn't instantiated.  See
ThePhD/sol2#1606 and ThePhD/sol2#1648.

Imported from upstream MAME by @Rhys-T on 2024-12-25. Original commit:
mamedev/mame@c75845b

* Fix Clang 18.1+ warning about variable-length arrays in C++
  • Loading branch information
Rhys-T authored Jan 2, 2025
1 parent c7a4386 commit ee84a12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 3 additions & 6 deletions 3rdparty/sol2/sol/sol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6051,12 +6051,9 @@ namespace sol {
/// one.
///
/// \group emplace
template <class... Args>
T& emplace(Args&&... args) noexcept {
static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");

*this = nullopt;
this->construct(std::forward<Args>(args)...);
T& emplace(T& arg) noexcept {
m_value = &arg;
return **this;
}

/// Swaps this optional with the other.
Expand Down
5 changes: 5 additions & 0 deletions scripts/genie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,11 @@ end
"-Wno-bitwise-instead-of-logical", -- clang 14.0 complains about &, | on bools in asmjit
}
end
if version >= 180100 then
buildoptions {
"-Wno-vla-cxx-extension", -- clang 18.1 complains about variable-length arrays in C++ -- HBMAME
}
end
else
if version < 70000 then
print("GCC version 7.0 or later needed")
Expand Down

0 comments on commit ee84a12

Please sign in to comment.