Re: Assertions and Such



On Mon, Aug 21, 2000 at 04:53:23PM -0400, Sean Middleditch wrote:
> 
> ... Why wouldn't you kill warnings?  The messages from compilers and GTK 
> don't say: "Notice: you are using a deprecated API or your code needs 
> restructuring", they say: "Warning: there's a bug in your code else this 
> wouldn't be printed to the screen!!"
> 
Warnings from compilers can sometimes just be warnings, not bug reports.

$ cat t.c

int main(int argc, char* argv[]){
  int x = 1; // or get input from somewhere

  if (x)  { return 1; }
  if (!x) { return 0; }
  // control reaches here?
}

$ gcc -o t t.c

$ gcc -Wall -o t t.c
t.c: In function `main':
t.c:8: warning: control reaches end of non-void function

You could argue that the code was correct, as it always had a well defined
result. Should it be refactored so it's more obvious to the compiler what's
going on? Should that actually be classed as a bug?

> ... 
> I mean, simple things like an app always causes GTK to generate a warning 
> about passing a NULL pointer to some function....
>
I guess it's a bit trickier with runtime warnings generated by GTK. As an
app gets more complicated it's going to be harder to test all the various
bits of GUI code. Sitting at a computer randomly clicking on things trying
to get them to break doesn't sound like much fun ;)

Dave
-- 
They'll fight... and they'll win!
  -- Do you want to know more?      http://www.advogato.org/person/djs/





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