public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Peter Bigot <bigotp@acm.org>
To: Ian Lance Taylor <iant@google.com>
Cc: Andrew Haley <aph@redhat.com>, gcc@gcc.gnu.org
Subject: Re: RFC: -Wall by default
Date: Wed, 11 Apr 2012 16:45:00 -0000	[thread overview]
Message-ID: <CAPOJ94Ovb=5rjG0sJx2E-qX4pv0R+YmEJWSzovCwL07jFz2Axw@mail.gmail.com> (raw)
In-Reply-To: <mcrlim2i6nj.fsf@dhcp-172-18-216-180.mtv.corp.google.com>

On Wed, Apr 11, 2012 at 11:18 AM, Ian Lance Taylor <iant@google.com> wrote:
> Andrew Haley <aph@redhat.com> writes:
>
>> On 04/05/2012 01:28 PM, Michael Veksler wrote:
>>
>>> As for specific warnings, I hate that the the code (a&&b || c&&d),
>>> which did not cause a warning on older gcc version now gives a
>>> warning. I would not want it on by default since it forces users to
>>> write too many parentheses in ((a&&b)||(c&&d)) which makes the
>>> expression less readable. What next? Warn about (a*b+c*d) ? I would
>>> hate to write ((a*b)+(c*d)).
>>>
>>> Sure, the precedence of: << vs. +; & vs. == ; & vs. && ; is less
>>> clear and deserves a warning, but: & vs. | ; && vs. || ; are at
>>> least as common as * vs. + that programmers ought to know them.
>>
>> Absolutely so, yes.  I'd consider this a bug in gcc, just as if it
>> warned for arithmetic.
>
> This one is an interesting case, since there are strong arguments on
> both sides.
>
> I enabled the C++ warning about the precedence of && and || (it's been
> in C for many years).  It found real bugs in real code, bugs that had
> existed for years.

Indeed; although I follow GCC conventions while writing code for integration
into GCC, in my own code I'd much rather write ((a*b)+(c*d)) and deal with
any readability issues by adding whitespace.

Making the intent explicit seems safer than making assumptions about the
expertise level of the people who will be reading and maintaining the code,
or adding to the cognitive load of a maintainer who does remember the
precedence rules.

(Not even hinting for a change in GCC style: it's your bikeshed, I just
visit once in a while.)

Peter

  parent reply	other threads:[~2012-04-11 16:45 UTC|newest]

Thread overview: 201+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-04 18:34 Dominique Dhumieres
2012-04-04 21:22 ` Robert Dewar
2012-04-04 22:42   ` Gabriel Dos Reis
2012-04-05  1:27     ` Robert Dewar
2012-04-05  4:23       ` Gabriel Dos Reis
2012-04-05 10:34         ` Robert Dewar
2012-04-04 22:41 ` Gabriel Dos Reis
2012-04-04 22:57   ` Eric Botcazou
2012-04-04 23:04     ` Gabriel Dos Reis
2012-04-05  1:19       ` Robert Dewar
2012-04-05  4:17         ` Miles Bader
2012-04-05 10:27           ` Robert Dewar
2012-04-05 12:06             ` Vincent Lefevre
2012-04-05 12:18               ` Robert Dewar
2012-04-05 12:30                 ` Vincent Lefevre
2012-04-05 13:10                   ` Erik Trulsson
2012-04-05 14:07                     ` Vincent Lefevre
2012-04-05 12:45                 ` Richard Guenther
2012-04-05 12:49                   ` Robert Dewar
2012-04-05 13:13                     ` Richard Guenther
2012-04-05  4:21         ` Gabriel Dos Reis
2012-04-05  6:40           ` Arnaud Charlet
2012-04-05 10:42             ` Robert Dewar
2012-04-05 12:16               ` Vincent Lefevre
2012-04-05  9:36           ` Richard Guenther
2012-04-05  9:41             ` Gabriel Dos Reis
2012-04-05 11:46       ` Eric Botcazou
2012-04-05 12:29         ` Michael Veksler
2012-04-05 12:33           ` Robert Dewar
2012-04-05 12:43             ` Andrey Belevantsev
2012-04-05 13:16               ` Michael Veksler
2012-04-05 13:00             ` Michael Veksler
2012-04-05 13:17               ` Robert Dewar
2012-04-05 14:29             ` Gabriel Dos Reis
2012-04-06  2:17               ` Pedro Lamarão
2012-04-05 13:08           ` Basile Starynkevitch
2012-04-10 16:36           ` Andrew Haley
2012-04-11 16:18             ` Ian Lance Taylor
2012-04-11 16:23               ` Andrew Haley
2012-04-11 16:45               ` Peter Bigot [this message]
2012-04-11 19:20               ` Robert Dewar
2012-04-12  8:56               ` Fabien Chêne
2012-04-12  9:46                 ` Robert Dewar
2012-04-12  9:55                   ` Miles Bader
2012-04-12  9:59                     ` Robert Dewar
2012-04-12 10:26                   ` Fabien Chêne
2012-04-12 10:44                   ` Andrew Haley
2012-04-12 13:04                     ` Robert Dewar
2012-04-12 13:31                       ` Andrew Haley
2012-04-12 14:37                         ` Robert Dewar
2012-04-12 14:48                           ` Andrew Haley
2012-04-12 15:29                             ` Robert Dewar
2012-04-12 15:35                             ` Robert Dewar
2012-04-12 17:34                               ` pcpa
2012-04-13 22:51                               ` Dave Korn
2012-04-05 14:25         ` Gabriel Dos Reis
2012-04-05  4:12 ` Miles Bader
2012-04-05  4:26   ` Gabriel Dos Reis
2012-04-05  4:34   ` Miles Bader
  -- strict thread matches above, loose matches on Subject: below --
2012-04-04  9:44 Gabriel Dos Reis
2012-04-04 11:30 ` Rick Hodgin
2012-04-04 12:08 ` Andrew Haley
2012-04-04 12:12   ` Gabriel Dos Reis
2012-04-04 12:15     ` Andrew Haley
2012-04-04 12:20       ` Richard Guenther
2012-04-04 12:29         ` Gabriel Dos Reis
2012-04-04 14:57   ` Ian Lance Taylor
2012-04-04 15:07     ` Andrew Haley
2012-04-04 15:17       ` Ian Lance Taylor
2012-04-05  9:32         ` Richard Guenther
2012-04-05  9:37           ` Gabriel Dos Reis
2012-04-04 18:03       ` Gabriel Dos Reis
2012-04-04 21:19         ` Robert Dewar
2012-04-04 21:20         ` Robert Dewar
2012-04-05 10:50         ` Andrew Haley
2012-04-05 14:21           ` Gabriel Dos Reis
2012-04-10 13:32             ` Andrew Haley
2012-04-10 13:54               ` Miles Bader
2012-04-04 15:17     ` Jeff Law
2012-04-04 18:04       ` Gabriel Dos Reis
2012-04-04 18:07         ` Jeff Law
2012-04-04 18:11           ` Gabriel Dos Reis
2012-04-04 19:01             ` Andrew Haley
2012-04-05 10:50               ` Vincent Lefevre
2012-04-05 10:56                 ` Andrew Haley
2012-04-05 11:31                   ` Vincent Lefevre
2012-04-10 13:48                     ` Andrew Haley
2012-04-11  8:04                       ` Vincent Lefevre
2012-04-04 18:00     ` Gabriel Dos Reis
2012-04-07 21:47       ` James Cloos
2012-04-07 22:06         ` Gabriel Dos Reis
2012-04-07 22:32         ` Miles Bader
2012-04-08 15:18           ` James Cloos
2012-04-08 15:25             ` Gabriel Dos Reis
2012-04-08 17:56             ` Jonathan Wakely
2012-04-08 18:51               ` Robert Dewar
2012-04-08 19:34                 ` Gabriel Dos Reis
2012-04-08 19:53                   ` Robert Dewar
2012-04-08 20:24                     ` Gabriel Dos Reis
2012-04-08 20:28                       ` Robert Dewar
2012-04-08 20:57                         ` Gabriel Dos Reis
2012-04-08 19:37                 ` Jonathan Wakely
2012-04-08 19:55                   ` Robert Dewar
2012-04-08 20:03                     ` Jonathan Wakely
2012-04-08 20:13                       ` Robert Dewar
2012-04-08 20:26                         ` Gabriel Dos Reis
2012-04-08 20:30                           ` Robert Dewar
2012-04-08 21:00                             ` Gabriel Dos Reis
2012-04-08 21:41                               ` Robert Dewar
2012-04-08 20:25                     ` Gabriel Dos Reis
2012-04-08 20:29                       ` Robert Dewar
2012-04-09 16:30                     ` Gerald Pfeifer
2012-04-09 16:40                       ` Paul_Koning
2012-04-09 17:08                       ` Gabriel Dos Reis
2012-04-09 17:15                         ` Robert Dewar
2012-04-09 17:29                           ` Gabriel Dos Reis
2012-04-09 17:31                             ` Robert Dewar
2012-04-09 17:31                         ` Eric Botcazou
2012-04-09 17:33                           ` Robert Dewar
2012-04-09 17:36                           ` Jonathan Wakely
2012-04-09 17:44                             ` Robert Dewar
2012-04-09 18:03                               ` Gabriel Dos Reis
2012-04-09 20:31                                 ` Andreas Schwab
2012-04-10  6:11                                   ` James Cloos
2012-04-10  6:27                                     ` Eric Botcazou
2012-04-10  7:08                                       ` Miles Bader
2012-04-10  7:37                                         ` Gabriel Dos Reis
2012-04-10 12:41                                           ` Michael Matz
2012-04-10 14:18                                             ` Gabriel Dos Reis
2012-04-10 14:39                                             ` Gabriel Dos Reis
2012-04-11  8:51                                 ` Vincent Lefevre
2012-04-12 10:23                                   ` Dave Korn
2012-04-12 12:34                                     ` Diego Novillo
2012-04-12 14:27                                     ` Gabriel Dos Reis
2012-04-12 14:39                                       ` Robert Dewar
2012-04-12 14:44                                         ` Gabriel Dos Reis
2012-04-12 14:46                                           ` Dave Korn
2012-04-12 14:55                                             ` Gabriel Dos Reis
2012-04-12 15:01                                               ` Dave Korn
2012-04-12 15:06                                                 ` Gabriel Dos Reis
2012-04-12 15:16                                                   ` Robert Dewar
2012-04-12 15:23                                                     ` Gabriel Dos Reis
2012-04-12 15:33                                                       ` Robert Dewar
2012-04-12 15:38                                                         ` Jonathan Wakely
2012-04-12 15:49                                                           ` Gabriel Dos Reis
2012-04-12 16:03                                                             ` Gabriel Dos Reis
2012-04-12 20:55                                                               ` Dave Korn
2012-04-12 21:36                                                                 ` Gabriel Dos Reis
2012-04-12 21:39                                                                   ` Robert Dewar
2012-04-12 21:40                                                                     ` Gabriel Dos Reis
2012-04-12 21:42                                                                       ` Robert Dewar
2012-04-12 21:48                                                                         ` Gabriel Dos Reis
2012-04-12 21:51                                                                           ` Robert Dewar
2012-04-13  6:04                                                                             ` Gabriel Dos Reis
2012-04-13  9:53                                                                               ` Robert Dewar
2012-04-12 21:30                                                             ` Jonathan Wakely
2012-04-12 21:37                                                               ` Gabriel Dos Reis
2012-04-12 15:44                                                       ` Pedro Alves
2012-04-12 15:52                                                         ` Gabriel Dos Reis
2012-04-12 16:08                                                           ` Pedro Alves
2012-04-12 15:24                                                   ` Dave Korn
2012-04-12 15:48                                                     ` Gabriel Dos Reis
2012-04-12 20:59                                                       ` Dave Korn
2012-04-12 21:37                                                         ` Gabriel Dos Reis
2012-04-13 22:39                                                           ` Dave Korn
2012-04-13 23:18                                                             ` Gabriel Dos Reis
2012-04-13 21:46                                   ` Oleg Smolsky
2012-04-13 22:46                                     ` Dave Korn
2012-04-14  0:10                                       ` NightStrike
2012-04-14  0:18                                         ` Chris Lattner
2012-04-09 18:03                             ` Gabriel Dos Reis
2012-04-11  8:30               ` Vincent Lefevre
2012-04-05  8:58 ` Pedro Alves
2012-04-05  9:32   ` Gabriel Dos Reis
2012-04-05  9:39     ` Richard Guenther
2012-04-05  9:47       ` Gabriel Dos Reis
2012-04-05  9:51         ` Richard Guenther
2012-04-05 10:01           ` Gabriel Dos Reis
2012-04-05 10:04             ` Arnaud Charlet
2012-04-05 10:12               ` Gabriel Dos Reis
2012-04-05 10:16                 ` Arnaud Charlet
2012-04-05 10:22                   ` Gabriel Dos Reis
2012-04-05 10:30                     ` Arnaud Charlet
2012-04-05 14:19                       ` Gabriel Dos Reis
2012-04-05 20:24                         ` Russ Allbery
2012-04-05 20:32                           ` Gabriel Dos Reis
2012-04-05 20:44                           ` Robert Dewar
2012-04-11  7:28                             ` Vincent Lefevre
2012-04-05 10:24                   ` Gabriel Dos Reis
2012-04-05 14:00                   ` Jonathan Wakely
2012-04-05 10:03           ` Gabriel Dos Reis
2012-04-05 13:58             ` Jonathan Wakely
2012-04-05 13:59               ` Gabriel Dos Reis
2012-04-07 22:41         ` Dave Korn
2012-04-07 22:57           ` Miles Bader
2012-04-07 23:03             ` Gabriel Dos Reis
2012-04-07 23:08             ` Robert Dewar
2012-04-07 22:58           ` Gabriel Dos Reis
2012-04-08 17:22             ` Dave Korn
2012-04-05  9:48       ` Pedro Alves
2012-04-05 11:11         ` Vincent Lefevre

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='CAPOJ94Ovb=5rjG0sJx2E-qX4pv0R+YmEJWSzovCwL07jFz2Axw@mail.gmail.com' \
    --to=bigotp@acm.org \
    --cc=aph@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.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).