Fix compiling on arm64 Linux with GCC #103303
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried to test compiling something in my arm64 Linux VM, specifically Ubuntu 24.04.2 LTS with GCC 13.3.0 and kernel 6.8.0, and I ran into this error:
It seems that the compiler is trying to inline this function, and giving a warning that it is out of bounds, even though it is not out of bounds. A simple fix is to store the buffer size in a variable. This also reduces code duplication. While I was at it, I also made
old_size
const.This only occurs on arm64 Linux with GCC. It doesn't occur with
scons use_llvm=yes
on the same system, and it doesn't occur on any other platforms as far as I can see. This problem also only occurs withVector<int8_t>
, it works fine for all the other integer sizes, however I made the same change for all of them for consistency, plus just in case some other platform out there is incorrectly inlining and warning for a different integer size.I'm very confident this doesn't change behavior, but I tested exporting and importing a
.glb
file and it still works correctly.