public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Carlo Wood <carlo@runaway.xs4all.nl>
To: rouaix@my-dejanews.com (Marc Rouaix)
Cc: egcs@cygnus.com (egcs@cygnus.com)
Subject: Re: suggest parentheses around assignment used as truth value
Date: Thu, 02 Jul 1998 07:08:00 -0000	[thread overview]
Message-ID: <199807011250.OAA00754@jolan.ppro> (raw)
In-Reply-To: <JMDHPDCIACOECAAA@my-dejanews.com>

| I'd just like to register my opiniont that code like
| 
| if (x = p()) {...}
| 
| shouldn't generate a warning under gcc -Wall.  Even if
| you feel that code like this is obscure, the recommended
| 
| if ((x = p())) {...}
| 
| is just bizarre.
| 
| ---
| Marc

It is a very common mistake to type '=' where '==' was intended.
Using extra parentheses is a very logical way to make the code
more clear in what you mean.  Not only for the author itself,
but also for others that read the code later and wonder if this
is a typo/bug, or if it was intended (something not always clear
from the context).

My personal opinion is that this warning is so useful that I'd
even object to move it to -pedantic warnings.

-- 
 Carlo Wood  <carlo@runaway.xs4all.nl>

  parent reply	other threads:[~1998-07-02  7:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-30 19:49 Marc Rouaix
1998-07-01  2:51 ` Andreas Schwab
1998-07-01  9:20   ` Richard Earnshaw
1998-07-01 21:20     ` Bill Currie
1998-07-02  7:08       ` Richard Earnshaw
1998-07-03  3:31         ` Nathan Sidwell
1998-07-03  6:15           ` Richard Earnshaw
1998-07-01  3:42 ` Branko Cibej
1998-07-02  7:08 ` Carlo Wood [this message]
1998-07-03 14:48   ` Kamil Iskra
1998-07-01  4:00 Brad M. Garcia
1998-07-01 20:20 ` Tim Hollebeek
1998-07-02  1:39 ` Harvey J. Stein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199807011250.OAA00754@jolan.ppro \
    --to=carlo@runaway.xs4all.nl \
    --cc=egcs@cygnus.com \
    --cc=rouaix@my-dejanews.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).