Skip to content

Fix gcc16 -Werror compile issues - #3784

Merged
oddbookworm merged 1 commit into
mainfrom
ankith26-gcc16
May 9, 2026
Merged

oddbookworm merged 1 commit into
mainfrom
ankith26-gcc16

Conversation

@ankith26

@ankith26 ankith26 commented May 2, 2026

Copy link
Copy Markdown
Member

PR to fix the Fedora 44 compile time issues initially reported by @DickerDackel on discord. Fedora 44 is the first major distro to ship with the latest GCC 16. This new GCC version now raises more warnings which become errors in dev.py install.

This PR reorganizes some includes to ensure that Python.h is always included first. This fixes _XOPEN_SOUCE/_POSIX_C_SOURCE macro redefinition issues. It also adds extra error checking in one place for bpp to silence new size warnings.

@ankith26
ankith26 requested a review from a team as a code owner May 2, 2026 18:16
@coderabbitai

coderabbitai Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cda8f44a-4cc2-497f-a2f5-f0f6519d858b

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between f812404 and 7daa6c9.

πŸ“’ Files selected for processing (5)
  • src_c/font.h
  • src_c/include/pygame_font.h
  • src_c/pixelcopy.c
  • src_c/scrap.c
  • src_c/surface.h
πŸ’€ Files with no reviewable changes (2)
  • src_c/include/pygame_font.h
  • src_c/surface.h
βœ… Files skipped from review due to trivial changes (2)
  • src_c/font.h
  • src_c/scrap.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • src_c/pixelcopy.c

πŸ“ Walkthrough

Walkthrough

Reorders C header includes across several source and header files and adds bytes-per-pixel validation to pixelcopy routines, raising ValueError and returning -1 for unsupported pixel sizes.

Changes

Include reorganization & pixel-size validation

Layer / File(s) Summary
Public header change
src_c/include/pygame_font.h
Removed #include <Python.h> from the public font header; public declarations unchanged.
Internal header change
src_c/font.h
Adds #include <Python.h> so Python API macros/types are available for this internal header.
SDL/include consolidation
src_c/surface.h
Removed conditional SDL3/SDL.h vs SDL.h include block; header now proceeds to #include "pygame.h".
Implementation include ordering
src_c/pixelcopy.c
Moved #include "pygame.h" earlier in the file (removed the later redundant include).
Implementation include ordering
src_c/scrap.c
Replaced multiple explicit C/SDL includes with unconditional #include "pygame.h" and conditional #include <SDL_syswm.h> only when PG_SDL3 is not defined.
Validation logic
src_c/pixelcopy.c
Added pixelsize validation to _copy_colorplane and _copy_unmapped: if `pixelsize > 4

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Code quality/robustness, bugfix, image

Suggested reviewers

  • Starbuck5
  • MyreMylar
πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The title accurately describes the main objective of the PRβ€”fixing GCC 16 compilation errorsβ€”which aligns with the core changes across all modified files.
Description check βœ… Passed The description clearly explains the problem (Fedora 44/GCC 16 compile-time failures), the solution (reorganizing includes and adding error checking), and is directly related to all changes in the changeset.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ankith26-gcc16

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src_c/pixelcopy.c`:
- Around line 278-282: surface_to_array still calls _copy_unmapped for ndim==3
and _copy_unmapped writes pixelsize bytes into the 4-byte _pc_pixel_t union, so
add the same guard used for _copy_colorplane: check pixelsize <=
sizeof(_pc_pixel_t) (or <=4) before allowing the unmapped/deep-color path and
raise PyExc_ValueError via PyErr_Format if it exceeds that; update the
conditional logic in surface_to_array (the branch that routes to _copy_unmapped
for ndim==3) to perform this check and fail early to prevent out-of-bounds
writes into _pc_pixel_t.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2b4ab4d3-c9c0-4935-98ca-2dc93892f27e

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 05b1265 and f812404.

πŸ“’ Files selected for processing (5)
  • src_c/font.h
  • src_c/include/pygame_font.h
  • src_c/pixelcopy.c
  • src_c/scrap.c
  • src_c/surface.h
πŸ’€ Files with no reviewable changes (2)
  • src_c/include/pygame_font.h
  • src_c/surface.h

Comment thread src_c/pixelcopy.c Resolved
@Starbuck5 Starbuck5 added the Code quality/robustness Code quality and resilience to changes label May 2, 2026
@ankith26 ankith26 added this to the 2.5.8 milestone May 8, 2026

@oddbookworm oddbookworm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed the issue for me, thanks! πŸŽ‰

@oddbookworm
oddbookworm merged commit 747df97 into main May 9, 2026
34 checks passed
@ankith26
ankith26 deleted the ankith26-gcc16 branch May 9, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code quality/robustness Code quality and resilience to changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants