Repository navigation
widget: fix -Wmaybe-uninitialized error in scroll_bar with GCC 16 - #198
igagis-bot wants to merge 3 commits into
Conversation
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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #198 +/- ##
==========================================
+ Coverage 28.53% 28.56% +0.02%
==========================================
Files 239 239
Lines 8943 8942 -1
Branches 2785 2785
==========================================
+ Hits 2552 2554 +2
+ Misses 6057 6054 -3
Partials 334 334 ☔ View full report in Codecov by Harness. |
| # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" | ||
| #endif | ||
| scroll_bar::scroll_bar( // | ||
| const utki::shared_ref<ruis::context>& c, |
Use '#'+tab before the pragma directive, as required by the project's clang-format configuration.
| // load default resources if not provided | ||
| // NOTE: cannot be done in the member initializer list, GCC complains | ||
| // about a possibly-uninitialized value there | ||
| if (!this->params.background) { |
There was a problem hiding this comment.
what exactly was GCC complaining about? since you moved these out of the initializer list, then why do you suppress warnings with the pragma?
There was a problem hiding this comment.
GCC 16 -Wmaybe-uninitialized false positive: in the old code the context base-class member (a utki::shared_ref<ruis::context> initialized by the preceding widget(...) base-class constructor call) was dereferenced via context.get() inside the params([&]{...}()) member initializer. GCC 16 cannot track that the base-class member is already initialized by the time the following initializers run, and reports a possibly-uninitialized read of it, which breaks the build with -Werror.
I moved the loading into the constructor body (where GCC 16 is happy, since the base class is fully constructed there) and kept the pragma as a guard around the whole constructor, because I could not re-verify locally that the body move alone is sufficient on GCC 16 — I only have GCC 14 available here.
If you can confirm that the body move alone is clean on GCC 16, I can drop the pragma in a follow-up commit; happy to also retest on a GCC 16 toolchain if you point me to one.
- rename 'c' parameter to 'context' - use this->context style in the initializer list and constructor body
GCC 16 raises a false-positive
-Wmaybe-uninitializedin thescroll_barconstructor (it cannot track values initialized before the use across base class constructor calls), breaking the build with-Werror.Move the default resource loading into the constructor body and suppress the warning for GCC 16 (guarded by
CFG_COMPILER/CFG_COMPILER_VERSION_MAJOR).Verified with a full build and the complete test suite (353 ruis tests pass).