Skip to content
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

[3.x] Fix various GCC 13 warnings #85917

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Dec 8, 2023

Fixes occurrences of -Wtype-limits, -Wmaybe-uninitialized, -Wduplicated-branches.

Includes 3.x version of #85500.

@akien-mga akien-mga added this to the 3.6 milestone Dec 8, 2023
@akien-mga akien-mga requested a review from a team as a code owner December 8, 2023 12:34
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, makes sense

@akien-mga akien-mga force-pushed the 3.x-fix-Wtype-limits-gcc-arm64 branch from ec5c7e1 to d8ead9b Compare December 8, 2023 14:10
@akien-mga akien-mga requested review from a team as code owners December 8, 2023 14:10
@akien-mga akien-mga changed the title [3.x] String: Fix GCC -Wtype-limits warning on Linux arm64 [3.x] Fix various GCC 13 warnings Dec 8, 2023
@akien-mga
Copy link
Member Author

Added some more warning fixes.

This doesn't yet allow building 3.x with GCC 13.2.0 warning free, as I ran into this more complex one:

In file included from drivers/gles2/rasterizer_canvas_gles2.h:34,
                 from drivers/gles2/rasterizer_canvas_gles2.cpp:31:
In member function 'RasterizerCanvasBatcher<T, T_STORAGE>::Batch* RasterizerCanvasBatcher<T, T_STORAGE>::_batch_request_new(bool) [with T = RasterizerCanvasGLES2; T_STORAGE = RasterizerStorageGLES2]',
    inlined from 'void RasterizerCanvasBatcher<T, T_STORAGE>::_prefill_default_batch(FillState&, int, const RasterizerCanvas::Item&) [with T = RasterizerCanvasGLES2; T_STORAGE = RasterizerStorageGLES2]' at ./drivers/gles_common/rasterizer_canvas_batcher.h:891:48,
    inlined from 'void RasterizerCanvasBatcher<T, T_STORAGE>::_prefill_default_batch(FillState&, int, const RasterizerCanvas::Item&) [with T = RasterizerCanvasGLES2; T_STORAGE = RasterizerStorageGLES2]' at ./drivers/gles_common/rasterizer_canvas_batcher.h:844:1:
./drivers/gles_common/rasterizer_canvas_batcher.h:689:31: error: 'void* memset(void*, int, size_t)' offset [0, 29] is out of the bounds [0, 0] [-Werror=array-bounds=]
  689 |                         memset(batch, 0, sizeof(Batch));
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In member function 'RasterizerCanvasBatcher<T, T_STORAGE>::Batch* RasterizerCanvasBatcher<T, T_STORAGE>::_batch_request_new(bool) [with T = RasterizerCanvasGLES2; T_STORAGE = RasterizerStorageGLES2]',
    inlined from 'void RasterizerCanvasBatcher<T, T_STORAGE>::_prefill_default_batch(FillState&, int, const RasterizerCanvas::Item&) [with T = RasterizerCanvasGLES2; T_STORAGE = RasterizerStorageGLES2]' at ./drivers/gles_common/rasterizer_canvas_batcher.h:917:47,
    inlined from 'void RasterizerCanvasBatcher<T, T_STORAGE>::_prefill_default_batch(FillState&, int, const RasterizerCanvas::Item&) [with T = RasterizerCanvasGLES2; T_STORAGE = RasterizerStorageGLES2]' at ./drivers/gles_common/rasterizer_canvas_batcher.h:844:1:
./drivers/gles_common/rasterizer_canvas_batcher.h:689:31: error: 'void* memset(void*, int, size_t)' offset [0, 29] is out of the bounds [0, 0] [-Werror=array-bounds=]
  689 |                         memset(batch, 0, sizeof(Batch));
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

GCC seems to disagree with @lawnjelly's comment:

			// this should always succeed after growing
			batch = bdata.batches.request();
			RAST_DEBUG_ASSERT(batch);

(that RAST_DEBUG_ASSERT is a no-op in release builds, and batch is used later without checking if it's nullptr)

@akien-mga akien-mga added the cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release label Dec 8, 2023
Fixes occurrences of `-Wtype-limits`, `-Wmaybe-uninitialized`,
`-Wduplicated-branches`.
@akien-mga akien-mga force-pushed the 3.x-fix-Wtype-limits-gcc-arm64 branch from d8ead9b to 02e4e20 Compare December 8, 2023 14:33
@akien-mga akien-mga requested a review from a team as a code owner December 8, 2023 14:33
@akien-mga
Copy link
Member Author

Ok, done. Aside from the warning in RasterizerCanvasBatcher, the 3.x branch now compiles warning free with both tools=yes target=release_debug dev=yes and tools=no target=release dev=yes.

Might be some other warnings in some other tools/target/optimization configs but that's a good pass already.

@lawnjelly
Copy link
Member

GCC seems to disagree with @lawnjelly's comment:
// this should always succeed after growing

My comment should probably more accurately be:
// this should always succeed after growing UNLESS OUT OF MEMORY AND WORLD IS ENDING

@akien-mga akien-mga merged commit 1fe73d4 into godotengine:3.x Dec 11, 2023
13 checks passed
@akien-mga akien-mga deleted the 3.x-fix-Wtype-limits-gcc-arm64 branch December 11, 2023 19:03
@akien-mga
Copy link
Member Author

Cherry-picked for 3.5.4.

@akien-mga akien-mga removed the cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants