CesiumGS / cesium-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I3dmToGltfConverter.cpp Wmaybe-unititialized Error

MilesMena opened this issue · comments

When I was building, I was getting a Wmaybe-uninitialized error. In the folder Desium3DTilesContent there's a file that is in the title above and at line 630 in the function CopyInstanceToBuffer that has three variables uninitialized. I replaced said functions with
void copyInstanceToBuffer( const glm::dmat4& instanceTransform, std::vector<std::byte>& bufferData, size_t i) { glm::dvec3 position(0.0); // Initialize position with default values glm::dvec3 scale(1.0); // Initialize scale with default values glm::dvec3 skew(0.0); glm::dquat rotation; glm::dvec4 perspective; decompose(instanceTransform, scale, rotation, position, skew, perspective); copyInstanceToBuffer(position, rotation, scale, bufferData, i); }
And the build compiled succesfully.

Hi,
Can you give some more details about the compilation environment? Were you compiling cesium-native as part of a Cesium plugin, or for an external project?

Depending on the compiler, and I'm assuming that this is gcc, -Wmaybe-uninitialized coupled with -Werror can give a lot of false positives, as it has in this case.

I'm on ubuntu 22.04 and gcc version 11.4.0

@MilesMena in general we can't guarantee that cesium-native compiles with extra warnings-as-errors enabled that we don't use ourselves. And I agree with Tim that there's no actual uninitialized usage here. So I'm going to close this issue.

I suggest you adjust your warning settings when building cesium-native.

Or, alternatively, consider opening a pull request that adds this warning to the set that we build with ourselves:

target_compile_options(${targetName} PRIVATE -Werror -Wall -Wextra -Wconversion -Wpedantic -Wshadow -Wsign-conversion)

The PR should also fix any new warnings that pop up as a result. We'd likely be happy to merge such a PR.