[Bug driver/63660] New: [4.8-4.9+] -Wmaybe-uninitialized false positive with -O1 and more
ed0.88.prez at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 27 18:32:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63660
Bug ID: 63660
Summary: [4.8-4.9+] -Wmaybe-uninitialized false positive with
-O1 and more
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: driver
Assignee: unassigned at gcc dot gnu.org
Reporter: ed0.88.prez at gmail dot com
Here, this code:
cat bug.i
typedef struct
{
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
} X;
X *XX(int);
int G();
static void F()
{
X *x;
int m, n;
int xa, xb, xc, xd, xe, xf, xg, xh, xi, xj;
m = G();
n = G();
if ( n & 1 ) xa = G();
if ( n & 2 ) xb = G();
if ( n & 4 ) xc = G();
if ( n & 32 ) xd = G();
if ( n & 16 ) xe = G();
if ( n & 64 ) xf = G();
if ( n & 256 ) xg = G();
if ( n & 512 ) xh = G();
if ( n & 1024 ) xi = G();
if ( n & 2048 ) xj = G();
if ( m >= 64 ) return;
x = XX(m);
if ( n & 1 ) x->a = xa;
if ( n & 2 ) x->b = xb;
if ( n & 4 ) x->c = xc;
if ( n & 32 ) x->d = xd;
if ( n & 16 ) x->e = xe;
if ( n & 64 ) x->f = xf;
if ( n & 256 ) x->g = xg;
if ( n & 512 ) x->h = xh;
if ( n & 1024 ) x->i = xi;
if ( n & 2048 ) x->j = xj;
}
void H()
{
F();
}
EOF
Compiled with -O1 -Wmaybe-uninitialized (implied by -Wall), reports this
message:
bug.i: In function ‘H’:
bug.i:49:23: warning: ‘xj’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
if ( n & 2048 ) x->j = xj;
^
bug.i:23:42: note: ‘xj’ was declared here
int xa, xb, xc, xd, xe, xf, xg, xh, xi, xj;
^
This code is a very reduced testcase from a large program.
More information about the Gcc-bugs
mailing list