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: a warning to implement


Gabriel Dos Reis <gdr@codesourcery.com> writes:

> What I'm saying is that if you want to be warned about that construct
> then you should explicitly turn on the appropriate flag.  In this
> case, I do think -Walll should -not- turn that flag on.  

The manual says this about -Wall:

  `-Wall'
       All of the above `-W' options combined.  This enables all the
       warnings about constructions that some users consider
       questionable, and that are easy to avoid (or modify to prevent the
       warning), even in conjunction with macros.

An example of a warning produced by -Wall:

  void foo (const char* p, char* q)
  {
    while (*q = *p)
      { ++q; ++p; }
  }

  test.cc: In function `void foo(const char *, char *)':
  test.cc:3: warning: suggest parentheses around assignment used as truth value

It is clear that _some_ users consider assignment as truth value
questionable, and it is easy to avoid.  Thus, it is a good example of
a -Wall warning.  Just to set the level we are talking about.

Are you saying the "T x = x" is less questionable or harder to work
around than the above?

Personally, not being one of the super programmers on this list, I have
lost a couple of days work debugging errors caused by accidental use
of the "T x = x" construct, which I at the time didn't even knew was
legal, so I would have loved to have had a warning with -Wall, but
wouldn't even have thought of searching for a separate flag.


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