This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Should -Wjump-misses-init be in -Wall?


Gabriel Dos Reis wrote:
On Tue, Jun 23, 2009 at 11:12 AM, Joe Buck<Joe.Buck@synopsys.com> wrote:
On Tue, Jun 23, 2009 at 12:43 AM, Alan Modra<amodra@bigpond.net.au> wrote:
..., but I think this warning should be in -Wc++-compat, not -Wall
or even -Wextra.  Why?  I'd argue the warning is useless for C code,
unless you care about C++ style.
On Tue, Jun 23, 2009 at 12:35:48AM -0700, Gabriel Dos Reis wrote:
I do not think it is useless for C99 codes because C99 allows
C++ style declarations/initialization in the middle of a block.
But if the initialization is skipped and the variable is then used,
won't we get an uninitialized-variable warning?

Did we get any in the cases Ian reported?

No, because they were all like this:


goto fail;

 ...
  int a = ...;
  if (a)
    {
     fail:
      // does not use a
      return;
    }

...

This is a bit ugly, but it's valid C code.

The only dubious one in my opinion was a missing bracket around switch, which was also harmless but warrants a warning. This however could be implemented as a separate warning going into -Wextra.

I don't think this warning can report anything that -Wuninitialized cannot report, so it should go in -Wc++-compat only.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]