On 18 Jun, 14:15, Richard<rgr...@gmail.com> wrote:
> santosh <santosh....@gmail.com> writes:
> > Richard Heathfield wrote:
>
> >> santosh said:
>
> >>> Richard Heathfield wrote:
>
> >>>> santosh said:
>
> >>>>> Bill Cunningham wrote:
>
> >>>>> [ ... ]
>
> >>>>>> I use fprintfs to stderr so there's an error only if there's an
> >>>>>> error.
>
> >>>>> How do you come to this conclusion?
>
> >>>> What are you suggesting, santosh - that there might be an error even
> >>>> if there isn't an error?
>
> >>> I was asking Bill why "there's an error only if there's an error"
> >>> only when he is using fprintf. 
>
> >>> One or more errors could have occurred before the fprintf call,
> >>> perhaps after it, perhaps in the call itself. Fprintf doesn't
> >>> guarantee that you will spot all your errors.
>
> >> I've never heard of Fprintf - but you can't begin a sentence with a
> >> lower case letter! Ain't the English/C boundary wonderful? 
>
> >> Seriously, you are obviously right - it's our job to spot bugs, and
> >> fprintf is at best a tool that can help us to do that (just as a
> >> debugger is only a tool). Tools are useful, but only fools rely on
> >> them to do things they are not designed to do. We can *use* tools to
> >> do things they are not designed to do, but if we are wise we will
> >> recognise that they may not achieve the goal we intend.
>
> >> In this case, the best approach is probably to use a debugger to find
> >> out where the seg fault is occurring, and then apply one's brain to
> >> find the cause. Debuggers /can/ help with this, especially good ones
> >> that let you explore the state of the call stack (e.g. the Visual C++
> >> debugger, or gdb), but they are no magic wand, and no substitute for a
> >> clear head and a knowledge of the language.
>
> > I completely concur except to say that in this particular case a
> > debugger was not necessary because multiple cases of undefined
> > behaviour simply _stood_ _out_ at a first glance at the code.
>
> Would people stop stating this? OF COURSE some errors "simply stand
> out". But *even* in those cases it does no harm to use one. Sheesh.- Hide quoted text -
ok this is boring. I suspect people are ignoring your THE DEBUGGEr IS
KING stuff
because we've heard it before. But this is once (n?) too many.
- debuggers are useful
- for the record, I sometimes use a debugger
- not everyone finds single stepping throgh code useful
- there are other ways of debugging code
and in this case I can quite understand it is possible to debug the
program
in question without a debugger. Though Bill probably needs one. The
Undefined
Behaviour probaly dosn't leap out at him.
--
Nick Keighley