-
Notifications
You must be signed in to change notification settings - Fork 72
fix: redudant moves and unused variables warnings #114
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
Conversation
|
While I see the idea, I personally think these are invalid warnings. The code you referenced is templated code, and while the cases where the warnings appear are for types that do not have a copy-constructor, it would be unexpected behavior for types that do have a copy constructor. I explicitly want to use the move constructor in all of these places. GCC 15.1 locally also throws these warnings, but LLVM 20 does not. I mean technically one could write some if constexpr (std::is_copy_constructible_v<T>) {
return std::move(value);
} else {
return value;
}Therefore I feel like the proposed changes shouldn't be merged. I understand that people use |
a0a63b3 to
06d47e8
Compare
|
Hi @spnda I was a bit confused by what you meant and only then realized that I had actually removed Could I bother to take a look at this again ? You will find that the actual Sorry for the confusion |
Yes, |
|
The changes to |
All of the changes apart from the unused parameter warning fixes are for functions that return |
|
For member templated variables I completely agree! What I'm modifying is cases where we return a local variable and in that case it doesn't make sense to be explicit about the move since we would prevent the compiler from performing RVO (thank you for pointing me to the correct term) |
64ff538 to
ee55a81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that you've changed all standard factory constructors of GltfDataBuffer, you can also change the one guarded by FASTGLTF_CPP_20, which would have the same issue.
fastgltf/include/fastgltf/core.hpp
Lines 639 to 647 in ee55a81
| #if FASTGLTF_CPP_20 | |
| static Expected<GltfDataBuffer> FromSpan(std::span<std::byte> data) noexcept { | |
| GltfDataBuffer buffer(data); | |
| if (buffer.buffer.get() == nullptr) { | |
| return buffer.error; | |
| } | |
| return std::move(buffer); | |
| } | |
| #endif |
Also, since we've established the warnings to be correct, what about the templated functions? Could those be re-added?
ee55a81 to
9122526
Compare
Done, there's also one guarded by
The only [[nodiscard]] T&& operator*() && noexcept {
assert(err == Error::None);
return std::move(value);
}Which is moving a member variable so I believe this is necessary as the default here would be to copy to not invalidate a member variable There's some in |
If it's a local variable you can just change it, it ought to work.
Yea for member variables this is still necessary, as far as I understood only local variables are promoted to "xvalues" that are moved automatically. |
9122526 to
9ca1dbb
Compare
Sure thing, it's done :) |
|
Thank you very much 🚀 |
|
@AndreCostaaa May I ask if this is for LVGL or for one of your own projects? I'm currently doing embedded stuff with Zephyr so it's nice to see this project making its way into embedded environments, too, if that's the case. |
|
Hi @spnda This is indeed for LVGL, we've recently added 3D support and we are working on adding GLTF support :) |
Hi fantastic project you have here
While integrating it into a project with
-Wall -Wextra -WpedanticI got a bunch of warnings that I figured would resolve and contribute upstreamLet me know what you think
To reproduce the warnings: