Re: somebody dropped a (warning) bomb

From: Linus Torvalds
Date: Thu Feb 08 2007 - 19:23:41 EST




On Fri, 9 Feb 2007, J.A. Magallón wrote:
>
> Thats the point. Mmmm, I think I see it the other way around. I defined
> a variable as 'signed' or 'unsigned', because the sign info matters for me.
> And gcc warns about using a function on it that will _ignore_ or even
> misinterpret that info. Could it be a BUG ? Yes.

Sure. The other way of seeing it is that *anything* could be a bug.

Could adding 1 to "a" be a bug? Yes. "a" might overflow. So maybe the
compiler should warn about that too?

So do you think a compiler should warn when you do

int a = i + 1;

and say "warning: Expression on line x might overflow"?

Could it be a BUG? Hell yeah.

Is warning for things that _could_ be bugs sane? Hell NO.

> Linux/x86, gcc 4.1.2-0.20070115:
> werewolf:~> gcc -Wpointer-sign -c t.c
> t.c: In function ÿÿfÿÿ:
> t.c:10: warning: pointer targets in passing argument 1 of ÿÿstrlenÿÿ differ in signedness
> t.c:11: warning: pointer targets in passing argument 1 of ÿÿstrlenÿÿ differ in signedness

Yeah, and that's what I think is crazy.

Is it consistent? Yes. Does it help people? No.

A warning that is consistent is not necessarily a good warning. It needs
to MAKE SENSE too. And this one doesn't. I'm sorry if you can't see that.

Linus