Skip to content

agg: fix -Wmaybe-uninitialized error in gradient with GCC 16 - #4

Merged
igagis merged 5 commits into
cppfw:mainfrom
igagis-bot:fix-gcc16-gradient-warning
Nov 26, 2026
Merged

igagis merged 5 commits into
cppfw:mainfrom
igagis-bot:fix-gcc16-gradient-warning

Conversation

@igagis-bot

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

Copy link
Copy Markdown
Contributor

GCC 16 rejects the previous gradient base class layout with -Wmaybe-uninitialized under -Werror: the concrete gradient wrapper members are constructed after the base class, so the base class cannot initialize them in its constructor.

The base class (AGG backend) now keeps only the cur_grad pointer. The derived classes register their wrappers in a utki::enum_array in their constructor bodies and override the new protected pure virtual get_spread_method_wrapper(); the base set_spread_method() uses that accessor.

Verified with a full build and the complete test suite (557 veg tests pass).

The gradient wrapper members are constructed after the base class,
so the base class cannot initialize them in its constructor. GCC 16
rejects the previous layout with -Wmaybe-uninitialized under -Werror.

Store pointers initialized in the derived class constructor bodies
via init_gradients() instead.
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (b8c149e) to head (b8161a1).

Files with missing lines Patch % Lines
src/veg/gradient.cpp 0.00% 5 Missing ⚠️
src/veg/gradient.hpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main      #4   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          6       6           
  Lines        436     425   -11     
  Branches     120     121    +1     
=====================================
+ Misses       436     425   -11     

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

Comment thread src/veg/gradient.hpp Resolved
Comment thread src/veg/gradient.hpp Resolved
Comment thread src/veg/gradient.cpp Resolved
…lass

Address review: the base class only needs cur_grad. Derived classes set
it in their constructor bodies and override the now-virtual
set_spread_method() with their own wrappers.
Comment thread src/veg/gradient.cpp Resolved
Address review: instead of overriding set_spread_method() in the derived
classes, introduce the pure virtual protected
gradient::get_spread_method_wrapper() and override it in linear_gradient
and radial_gradient. The gradient wrappers are kept in a
utki::enum_array indexed by gradient_spread_method (added the enum_size
item to the enum). The base set_spread_method() implementation uses the
new accessor.
Comment thread src/veg/gradient.cpp Resolved
Comment thread src/veg/gradient.cpp Resolved
Comment thread src/veg/gradient.cpp Resolved
Address review: the spread wrappers array is now initialized in the
constructor initializer list, and the constructors set the initial
spread method via set_spread_method() instead of assigning cur_grad
directly.
Address the CI lint failure: format the new constructor initializer
lists per the project's clang-format configuration.
@igagis
igagis merged commit 192b614 into cppfw:main Nov 26, 2026
23 of 24 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