Re: 2.6.14 assorted warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Gwe, 2005-10-28 at 03:30 -0400, Dave Jones wrote:
> gcc is dumb, it doesn't realise that the variable will be filled by another
> function if its passed thus..
> 
> 	unsigned long foo
> 	bar(&foo)
> 	if (foo==1)
> 		...
> 
> With bar() filling in content of foo.
> I believe there's at least once instance of this in gcc bugzilla.

gcc is a *LOT* smarter than you give it credit for. It will not warn for
cases where it isn't able to tell how foo is used passed with &foo. It
will warn for cases where it can

Compile the following program with and without -O2 and you'll see just
how smart gcc actually is

#include <stdio.h>

static void bar(char *x) {
  *x = 1;
}

static void baz(char *x) {
  printf("Wombat\n");
}

int main(int argc, char *argv[]) {
  char x,y;
  bar(&x);
  baz(&y);

  printf("%c,%c\n", x, y);
}

So I'd go look deeper for real bugs 

Alan


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux