Skip to content

widget: fix -Wmaybe-uninitialized error in scroll_bar with GCC 16 - #198

Merged
igagis merged 4 commits into
cppfw:mainfrom
igagis-bot:fix-gcc16-scrollbar-warning
Nov 30, 2026
Merged

igagis merged 4 commits into
cppfw:mainfrom
igagis-bot:fix-gcc16-scrollbar-warning

Conversation

@igagis-bot

@igagis-bot igagis-bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

GCC 16 raises a false-positive -Wmaybe-uninitialized in the scroll_bar constructor (it cannot track values initialized before the use across base class constructor calls), breaking the build with -Werror.

Fix by renaming the c constructor parameter to context. Bare context in the remaining initializers then refers to the parameter (a plain function argument that GCC can track), so the warning disappears.

Note: context in the initializer list and the default resource loader lambda refers to the parameter, not the stored member this->context (which is a copy of the argument initialized by the virtual base constructor) — the two are the same shared_ref, so behavior is unchanged.

Verified with a full build and the complete test suite (353 ruis tests pass).

GCC 16 raises a false-positive -Wmaybe-uninitialized in the
scroll_bar constructor: it cannot track values initialized before
the use across base class constructor calls. Move the default
resource loading into the constructor body and suppress the
warning for GCC 16.
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 28.55%. Comparing base (f001323) to head (fa81908).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #198      +/-   ##
==========================================
+ Coverage   28.53%   28.55%   +0.02%     
==========================================
  Files         239      239              
  Lines        8943     8943              
  Branches     2785     2785              
==========================================
+ Hits         2552     2554       +2     
+ Misses       6057     6055       -2     
  Partials      334      334              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Comment thread src/ruis/widget/slider/scroll_bar.cpp Resolved
Comment thread src/ruis/widget/slider/scroll_bar.cpp Resolved
Comment thread src/ruis/widget/slider/scroll_bar.cpp Resolved
Use '#'+tab before the pragma directive, as required by the
project's clang-format configuration.
@igagis igagis self-assigned this Nov 27, 2026
Comment thread src/ruis/widget/slider/scroll_bar.cpp Resolved
- rename 'c' parameter to 'context'
- use this->context style in the initializer list and constructor body
…r rename

The earlier PR commits suppressed -Wmaybe-uninitialized via a GCC-only pragma,
moved default resource loading into the constructor body, and changed the
initializer list to use this->context. This reverts all of that, keeping only
the c -> context rename, which itself suppresses the warning.
@igagis
igagis merged commit 5b08766 into cppfw:main Nov 30, 2026
12 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants