Hi all, I've been going through a (really small) number of compile warnings and stumbled upon this one:
src/2geom/generic-interval.h: In member function 'Geom::Rect Inkscape::Filters::FilterPrimitive::filter_primitive_area(const Inkscape::Filters::FilterUnits&)': src/2geom/generic-interval.h:65:9: warning: 'y' may be used uninitialized in this function [-Wuninitialized] src/display/nr-filter-primitive.cpp:146:12: note: 'y' was declared here src/2geom/generic-interval.h:65:9: warning: 'x' may be used uninitialized in this function [-Wuninitialized] src/display/nr-filter-primitive.cpp:145:12: note: 'x' was declared here
(GCC 4.6.1 (tdm-1) on Windows)
The warning seems bogus to me, the value is certainly correctly initialized, and I've added code to check that everything that is assigned to it is also initialized. What fixes the warning is changing the first lines of that function Geom::OptRect const fa_opt = units.get_filter_area(); if (!bb_opt || !fa_opt) { return Geom::Rect (Geom::Point(0.,0.), Geom::Point(0.,0.)); } Geom::Rect const &bb = *bb_opt; Geom::Rect const &fa = *fa_opt; to Geom::OptRect const fa_opt = units.get_filter_area(); if (!bb_opt || !fa_opt) { return Geom::Rect (Geom::Point(0.,0.), Geom::Point(0.,0.)); } Geom::Rect const &bb = *bb_opt; Geom::Rect const &fa = *units.get_filter_area();
No joke... So, in conclusion: it will be impossible to compile with -Werror for now :'(, due to spurious compiler warnings that can't be avoided without hurting the code. (another one is templated functions with a signed comparison logic, that are then instantiated with unsigned template arguments...)
Disappointing :-( Johan
(PS. thanks for the help in fixing this)
2013/10/29 Johan Engelen <jbc.engelen@...2592...>:
The warning seems bogus to me, the value is certainly correctly initialized, and I've added code to check that everything that is assigned to it is also initialized. What fixes the warning is changing the first lines of that function (...)
Does that also happen if you put the assignments in an "else" branch?
I recall that GCC's control flow analysis is not perfect. For example having an if/else with a return statement in both branches could trigger a warning about missing return values.
Regards, Krzysztof
On 29-10-2013 22:07, Krzysztof Kosiński wrote:
2013/10/29 Johan Engelen <jbc.engelen@...2592...>:
The warning seems bogus to me, the value is certainly correctly initialized, and I've added code to check that everything that is assigned to it is also initialized. What fixes the warning is changing the first lines of that function (...)
Does that also happen if you put the assignments in an "else" branch?
I recall that GCC's control flow analysis is not perfect. For example having an if/else with a return statement in both branches could trigger a warning about missing return values.
Incredible. That actually worked... (r12751)
Cheers, Johan
participants (2)
-
Johan Engelen
-
Krzysztof Kosiński