[Bug middle-end/29574] Gcc gives invalid warning about unitialized variable

2006-10-23 Thread mbligh at mbligh dot org


--- Comment #8 from mbligh at mbligh dot org  2006-10-23 21:50 ---
> Initialize the variable and forget about inefficiency.  Again this is fixed 
> for
> 4.2.0, the warning is only because __builtin_expect gets in the way of 
> figuring
> out if the variable is used uninitialized, nothing more.

I understand the __builtin_expect case is fixed in 4.2, and am fine with that,
but I was talking about the ones that aren't inlined, and don't use
builtin_expect. Does gcc 4.2 walk through functions as well, or will it always
produce an invalid warning there?

Thanks, M.


-- 


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



[Bug middle-end/29574] Gcc gives invalid warning about unitialized variable

2006-10-23 Thread mbligh at mbligh dot org


--- Comment #6 from mbligh at mbligh dot org  2006-10-23 21:42 ---
Re the non-inlined functions ...
Have been discussing this with Andrew Morton.

what do we do then? Adding dead code to fix the fact that gcc can't see into
other functions is incorrect and inefficient.

Having lots of compiler warnings drowns out real ones, and is not acceptable.

How do we get around this? Can we at least get the option to not warn if it's
"blind" to the problem because it goes through another function, if not make
that the default?

gcc warnings are an incredibly valuable way to find code bugs if they're real.
If some are not real, we lose the benefit to all, as the real ones are drowned
in the noise.


-- 


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



[Bug middle-end/29574] Gcc gives invalid warning about unitialized variable

2006-10-23 Thread mbligh at mbligh dot org


--- Comment #4 from mbligh at mbligh dot org  2006-10-23 21:19 ---
And indeed, if I remove that unlikely(), it does work.

There's another set of these where the called initializer is not inlined,
ie:

int x;
initializer(&x);

Which it seems totally blind to, even if the initializer does "x = 0"
right at the top. Are those fixable?


-- 


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



[Bug middle-end/29574] Gcc gives invalid warning about unitialized variable

2006-10-23 Thread mbligh at mbligh dot org


--- Comment #3 from mbligh at mbligh dot org  2006-10-23 21:08 ---
Yeah, is builtin_expect ;-(

#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)


-- 


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



[Bug c/29574] New: Gcc gives invalid warning about unitialized variable

2006-10-23 Thread mbligh at mbligh dot org
Compile Linux 2.6.18 kernel. Warns that idx may be uninitialized in
fs/bio.c:bio_alloc_bioset(), but it clearly *is* being initialized
by bvec_alloc_bs. 

The kernel team will not allow us to pre-initialize these, as it is
a gcc bug. On the other hand, we're drowned in invalid warnings, so
can't see any real problems. Older versions of gcc (3.x) did not
have this problem.

struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
{
struct bio *bio = mempool_alloc(bs->bio_pool, gfp_mask);

if (likely(bio)) {
struct bio_vec *bvl = NULL;

bio_init(bio);
if (likely(nr_iovecs)) {
unsigned long idx;

bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
if (unlikely(!bvl)) {
mempool_free(bio, bs->bio_pool);
bio = NULL;
goto out;
}
bio->bi_flags |= idx << BIO_POOL_OFFSET;
bio->bi_max_vecs = bvec_slabs[idx].nr_vecs;
}
bio->bi_io_vec = bvl;
}
out:
return bio;
}

static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned
long *idx, struct bio_set *bs)
{
struct bio_vec *bvl;
struct biovec_slab *bp;

/*
 * see comment near bvec_array define!
 */
switch (nr) {
case   1: *idx = 0; break;
case   2 ...   4: *idx = 1; break;
case   5 ...  16: *idx = 2; break;
case  17 ...  64: *idx = 3; break;
case  65 ... 128: *idx = 4; break;
case 129 ... BIO_MAX_PAGES: *idx = 5; break;
default:
return NULL;
}
/*
 * idx now points to the pool we want to allocate from
 */

bp = bvec_slabs + *idx;
bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask);
if (bvl)
memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec));

return bvl;
}


-- 
   Summary: Gcc gives invalid warning about unitialized variable
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: mbligh at mbligh dot org


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