Uninitialized variables found by gcc-4.1.2

From: Juergen Weigert <jw_at_suse.de>
Date: Thu, 27 Jul 2006 00:31:58 +0200
To: prima_at_prima.eu.org

Hi everybody!

Compiling Prima-1.20 with gcc version 4.1.2 20060705 (prerelease) (SUSE Linux)
detects the following issues:

gcc -Wall -O2 -fPIC -c -Iinclude -Iinclude/generic -I/usr/lib/perl5/5.8.8/i586-linux-thread-multi/CORE -I/usr/local/include -I/usr/X11R6/include -I/usr/include/freetype2 -DHAVE_CONFIG_H=1 -o primguts.o primguts.c
In file included from primguts.c:69:
include/generic/thunks.tinc:4077:2: warning: no newline at end of file
include/generic/thunks.tinc: In function 'template_xs_p_Point_Handle_Bool_Point':
include/generic/thunks.tinc:3486: warning: '_apt_res_.y' is used uninitialized in this function
include/generic/thunks.tinc:3486: warning: '_apt_res_.x' is used uninitialized in this function
include/generic/thunks.tinc: In function 'template_rdf_p_Rect_Handle_Bool_Rect':
include/generic/thunks.tinc:1815: warning: '_apt_res_.left' is used uninitialized in this function
include/generic/thunks.tinc:1815: warning: '_apt_res_.bottom' is used uninitialized in this function
include/generic/thunks.tinc:1815: warning: '_apt_res_.right' is used uninitialized in this function
include/generic/thunks.tinc:1815: warning: '_apt_res_.top' is used uninitialized in this function
include/generic/thunks.tinc: In function 'template_rdf_p_Point_Handle_Bool_Point':
include/generic/thunks.tinc:1775: warning: '_apt_res_.x' is used uninitialized in this function
include/generic/thunks.tinc:1775: warning: '_apt_res_.y' is used uninitialized in this function
include/generic/thunks.tinc: In function 'template_rdf_p_NPoint_Handle_Bool_NPoint':
include/generic/thunks.tinc:1737: warning: '_apt_res_.x' is used uninitialized in this function
include/generic/thunks.tinc:1737: warning: '_apt_res_.y' is used uninitialized in this function

This is, because Prima/Gencls.pm which does not inject initialization code for _apt_res_
in case the 'goto CALL_POINT' is taken.
The following patch servers as an ugly workaround if applied after gencls.pl is done:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
--- Prima-1.20/include/generic/thunks.tinc.orig 2006-07-26 23:27:04.000000000 +0200
+++ Prima-1.20/include/generic/thunks.tinc 2006-07-26 23:35:59.000000000 +0200
@@ -1715,6 +1715,7 @@
         dSP;
         int _apt_count_;
         NPoint _apt_res_;
+ _apt_res_.x = _apt_res_.y = 0; // patch happiness in for GCC
 
         ENTER;
         SAVETMPS;
@@ -1753,6 +1754,7 @@
         dSP;
         int _apt_count_;
         Point _apt_res_;
+ _apt_res_.x = _apt_res_.y = 0; // patch happiness in for GCC
 
         ENTER;
         SAVETMPS;
@@ -1791,6 +1793,7 @@
         dSP;
         int _apt_count_;
         Rect _apt_res_;
+ _apt_res_.left = _apt_res_.bottom = _apt_res_.right = _apt_res_.top = 0; // patch happiness in for GCC
 
         ENTER;
         SAVETMPS;
@@ -3480,6 +3483,7 @@
                 croak( "Illegal object reference passed to %s", subName);
         {
                 Point _apt_res_;
+ _apt_res_.x = _apt_res_.y = 0; // patch happiness in for GCC
                 if ( !( items > 1)) goto CALL_POINT;
                 _apt_res_. x = ( int) SvIV( ST( 1));
                 _apt_res_. y = ( int) SvIV( ST( 2));
--- Prima-1.20/unix/xft.c.orig 2006-07-26 23:09:34.000000000 +0200
+++ Prima-1.20/unix/xft.c 2006-07-26 23:09:56.000000000 +0200
@@ -780,7 +780,7 @@
    os = FcObjectSetBuild( FC_FAMILY, FC_CHARSET, FC_ASPECT,
         FC_SLANT, FC_WEIGHT, FC_SIZE, FC_PIXEL_SIZE, FC_SPACING,
         FC_FOUNDRY, FC_SCALABLE, FC_DPI,
- 0);
+ (void *)0);
    s = FcFontList( 0, pat, os);
    FcObjectSetDestroy( os);
    FcPatternDestroy( pat);
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

(The xft.c patch silences a warning on 64bit architectures, where
integers are only 32 bit wide.)

cheers,
        Jw.

-- 
 o \  Juergen Weigert  paint it green! __/ _=======.=======_
<V> | jw_at_suse.de       wide open suse_/        _---|____________\/
 \  | 0911 74053-508         (tm)__/          (____/            /\
(/) | __________________________/             _/ \_ vim:set sw=2 wm=8
Received on Thu 27 Jul 2006 - 00:32:01 CEST

This archive was generated by hypermail 2.2.0 : Sat 19 Mar 2011 - 18:35:06 CET