Project

General

Profile

Bug #5108

value may be used uninitialized in rpcbind.c

Added by Gordon Ross almost 6 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2014-08-19
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

Building $SRC/cmd/rpcbind (on sparc)
rpcbind.c:1061: error: 'val' may be used uninitialized in this function [-Wuninitialized]
rpcbind.c:1084: error: 'val' may be used uninitialized in this function [-Wuninitialized]


Files


Related issues

Has duplicate illumos gate - Bug #5109: Variable uninitialized in rpcbind.cClosed2014-08-20

Actions
Is duplicate of illumos gate - Bug #5680: Build warnings in cmd/power, cmd/rpcbindClosed2015-03-04

Actions

History

#2

Updated by Marcel Telka almost 6 years ago

This is my analysis from May 2014:

http://www.listbox.com/member/archive/182179/2014/05/sort/time_rev/page/15/entry/9:432/20140505043921:BAD9DDDA-D430-11E3-AD65-F342923932F6/

I found that this problem is basically a bug in gcc:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145

I did some testing with the following simple testcase:

    int f(void);

    int
    main(void)
    {
        int a, b;

        a = f();
        if (a)
            b = f();

        if (a && b)
            return 1;

        return 0;
    }

Here are results on intel (on recent OpenIndiana hipster):

    $ /usr/bin/gcc --version
    gcc (GCC) 4.7.3
    Copyright (C) 2012 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ /usr/bin/gcc -O1 -Wuninitialized -c a.c 
    a.c: In function ‘main’:
    a.c:12:15: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    $ 
    $ 
    $ 
    $ /opt/gcc/4.4.4/bin/gcc --version
    gcc (Illumos gcc-4.4.4-il-3) 4.4.4
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ /opt/gcc/4.4.4/bin/gcc -O1 -Wuninitialized -c a.c 
    $

It is interesting that illumos-gcc 4.4.4 does NOT fail.

And here are results on sparc (I'm not sure about the patch level of these gcc
builds):

    $ uname -a
    SunOS bld5 5.11 1.3.6-sparc sun4u sparc SUNW,Sun-Fire-V440
    $ 
    $ 
    $ /usr/gcc/4.4/bin/gcc --version
    gcc (GCC) 4.4.7
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ /usr/gcc/4.4/bin/gcc -O1 -Wuninitialized -c a.c
    a.c: In function 'main':
    a.c:6: warning: 'b' may be used uninitialized in this function
    $ 
    $ 
    $ 
    $ /usr/gcc/4.7/bin/gcc --version
    gcc (GCC) 4.7.3
    Copyright (C) 2012 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ /usr/gcc/4.7/bin/gcc -O1 -Wuninitialized -c a.c
    a.c: In function 'main':
    a.c:12:15: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
    $ 
    $ 
    $ 
    $ /usr/gcc/4.8/bin/gcc --version
    gcc (GCC) 4.8.2
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ /usr/gcc/4.8/bin/gcc -O1 -Wuninitialized -c a.c
    a.c: In function 'main':
    a.c:12:15: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (a && b)
               ^
    $

I had no chance[*] to test this with illumos-gcc 4.4.4 on sparc to see whether
the issue is reproducible there or not.

[*] yet. But since I've no access to illumos-gcc 4.4.4 on sparc I do not plan
to test it.  If there is somebody with illumos-gcc 4.4.4 on sparc please run
the test. Thanks.
#3

Updated by Richard PALO almost 6 years ago

[corrected.. after restarting in a clean environment seemed okay]
Pedantically this is probably correct and is why -Wno-maybe-uninitialized exists...
The testsuite (following is pkgsrc 4.7.3) succeeds, and the above test program compiles without warning as well.

Executing on host: /tmp/pkgsrc/lang/gcc47/work/build/gcc/xgcc -B/tmp/pkgsrc/lang/gcc47/work/build/gcc/ /tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress.c    -fno-tree-ccp -fno-tree-vrp -O2 -Wuninitialized -Wno-maybe-uninitialized -S  -o uninit-suppress.s    (timeout = 300)
spawn /tmp/pkgsrc/lang/gcc47/work/build/gcc/xgcc -B/tmp/pkgsrc/lang/gcc47/work/build/gcc/ /tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress.c -fno-tree-ccp -fno-tree-vrp -O2 -Wuninitialized -Wno-maybe-uninitialized -S -o uninit-suppress.s
PASS: gcc.dg/uninit-suppress.c should be suppressed (test for bogus messages, line 15)
PASS: gcc.dg/uninit-suppress.c (test for excess errors)
Executing on host: /tmp/pkgsrc/lang/gcc47/work/build/gcc/xgcc -B/tmp/pkgsrc/lang/gcc47/work/build/gcc/ /tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress_2.c    -fno-tree-ccp -fno-tree-vrp -O2 -Wuninitialized -Werror=uninitialized -Wno-error=maybe-uninitialized -S  -o uninit-suppress_2.s    (timeout = 300)
spawn /tmp/pkgsrc/lang/gcc47/work/build/gcc/xgcc -B/tmp/pkgsrc/lang/gcc47/work/build/gcc/ /tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress_2.c -fno-tree-ccp -fno-tree-vrp -O2 -Wuninitialized -Werror=uninitialized -Wno-error=maybe-uninitialized -S -o uninit-suppress_2.s
/tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress_2.c: In function 'foo':
/tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress_2.c:15:8: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
output is:
/tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress_2.c: In function 'foo':
/tmp/pkgsrc/lang/gcc47/work/gcc-4.7.3/gcc/testsuite/gcc.dg/uninit-suppress_2.c:15:8: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]

PASS: gcc.dg/uninit-suppress_2.c should not be promoted to error (test for warnings, line 15)
PASS: gcc.dg/uninit-suppress_2.c (test for excess errors)

Naturally 'volatile' gets over it if relevant for the real case in hand.

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options or
https://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/Warning-Options.html#Warning-Options

#4

Updated by Marcel Telka about 5 years ago

  • Status changed from New to Closed

Fixed in #5680.

Also available in: Atom PDF