GNOME Bugzilla – Bug 771463
variable may be used uninitialized in gtk_widget_render
Last modified: 2016-09-15 09:19:37 UTC
When compiling gtk+ I get the following warning: home/sadiq/jhbuild/checkout/gtk+/gtk/gtkwidget.c: In function ‘gtk_widget_render’: /home/sadiq/jhbuild/checkout/gtk+/gtk/gtkwidget.c:17496:5: warning: ‘context’ may be used uninitialized in this function [-Wmaybe-uninitialized] gdk_window_end_draw_frame (window, context); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/sadiq/jhbuild/checkout/gtk+/gtk/gtkwidget.c:17463:22: note: ‘context’ was declared here GdkDrawingContext *context; ^~~~~~~ If gdk_window_has_native returns FALSE, context may have undefined value, which is used in gdk_window_end_draw_frame (window, context); (line 17496)
Which compiler is this? That's clearly a false positive. If gdk_window_has_native() returns FALSE we don't call gdk_window_begin_paint_internal(), but we still create a valid GdkDrawingContext instance. Additionally, since GDK is a separate shared library and compilation unit, any compiler cannot determine whether or not gdk_window_begin_draw_frame() may return NULL. The only two cases in which the GdkDrawingContext variable inside gtk_widget_render() can be unset are: * somebody called gdk_window_begin_draw_frame() in the middle of the rendering * somebody called gtk_widget_set_double_buffered() in the middle of the rendering Any other branch of gdk_window_begin_draw_frame() results in a GdkDrawingContext instance being returned. I have a fix for the priv->double_buffered condition being flipped in the middle of the rendering.
Pushed to master as: https://git.gnome.org/browse/gtk+/commit/?id=bb705837bc878b6028069fd7537e89975d50d2ee
(In reply to Emmanuele Bassi (:ebassi) from comment #1) > Which compiler is this? This is gcc6 on Fedora 24 relevant part from output of gcc --version: gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3)