Re: Program crashes when running it outside dev environment
- From: Harald van Dijk <truedfx@xxxxxxxxx>
- Date: Sat, 09 Jun 2007 00:22:02 +0200
Richard Heathfield wrote:
David Tiktin said:
On 08 Jun 2007, Richard Heathfield <rjh@xxxxxxxxxxxxxxx> wrote:
So my suggestions would be:
1) crank up your warning level to the max
2) turn off any extensions you can live without
3) fix every single diagnostic message, and *never* with a cast
I'm with you right up to the last clause. Are you saying you never
actually *need* a cast?
No, there are (rare) occasions when you do need a cast. But I don't know
of any occasion where you *need* a cast AND omitting it violates a
constraint or constitutes a syntax error. So adding a cast is not the
right way to fix a diagnostic message. If the choice is between adding
bad code and putting up with a bad warning, I'll live with the bad
warning.
I can't think of a concrete example of a cast which causes a constraint
violation or syntax error when left out either, but diagnostics are
permitted for other code as well.
#include <stdio.h>
int main(void) {
int *p = NULL;
printf("%p\n", p);
}
example.c:4: warning: format ‘%p’ expects type ‘void *’, but argument 2 has
type ‘int *’
And a cast is the right way to fix the bug.
.
- Follow-Ups:
- Re: Program crashes when running it outside dev environment
- From: Richard Heathfield
- Re: Program crashes when running it outside dev environment
- From: pete
- Re: Program crashes when running it outside dev environment
- From: Richard Tobin
- Re: Program crashes when running it outside dev environment
- References:
- Program crashes when running it outside dev environment
- From: z
- Re: Program crashes when running it outside dev environment
- From: Richard Heathfield
- Re: Program crashes when running it outside dev environment
- From: David Tiktin
- Re: Program crashes when running it outside dev environment
- From: Richard Heathfield
- Program crashes when running it outside dev environment
- Prev by Date: Re: Program crashes when running it outside dev environment
- Next by Date: Re: malloc without stdlib.h
- Previous by thread: Re: Program crashes when running it outside dev environment
- Next by thread: Re: Program crashes when running it outside dev environment
- Index(es):
Relevant Pages
|