bug-grep
[Top][All Lists]
Advanced

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

Re: avoid gcc 4.6.2 'may be used before set' warnings in dfa.c


From: Jim Meyering
Subject: Re: avoid gcc 4.6.2 'may be used before set' warnings in dfa.c
Date: Sat, 18 Feb 2012 17:53:11 +0100

Aharon Robbins wrote:
...
>> From: Paul Eggert <address@hidden>
...
>> Sorry, I don't see why this patch (and the other) is needed.
>> grep's copy of src/dfa.h says this:
>>
>> extern void dfaerror (const char *) __attribute__ ((noreturn));
>
> This would seem to be the difference. I don't have the __attribute__
> in my copy of dfa.h.  I don't remember the details, just that it caused
> some compilation problems on non-GCC compilers, so I removed it.

That's the problem.
If this definition from dfa.h can be improved, please report
the details of the offending compiler:

  #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__
  # define __attribute__(x)
  #endif

>> and all paths to the first use of c or wc lead
>> through either an initialization of them, or a call
>> to dfaerror.
>>
>> Also, all def-use paths for c1, c2, wc1, and wc2
>> seem sound, at least in grep's copy of dfa.c, so why
>> do they need to be initialized?
>
> The initializations don't hurt anything, either, and it's good practice
> to initialize one's variables.

An unnecessary initialization *does* impact readability,
and can mask used-uninitialized bugs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]