Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The world is coming to an end--save your buffers!


devel / comp.lang.c / Re: operator precedence

SubjectAuthor
* operator precedenceStefan Ram
+* Re: operator precedenceJames Kuyper
|+- Re: operator precedenceBen Bacarisse
|+* Re: operator precedenceSiri Cruise
||`* Re: operator precedencejames...@alumni.caltech.edu
|| `* Re: operator precedenceAndrey Tarasevich
||  +- Re: operator precedenceJames Kuyper
||  `- Re: operator precedenceJames Kuyper
|+- Re: operator precedenceScott Lurndal
|`- Re: operator precedenceBart
+- Re: operator precedenceAndrey Tarasevich
+* Re: operator precedenceStefan Ram
|`* Re: operator precedenceMike Terry
| `* Re: operator precedenceMike Terry
|  `* Re: operator precedenceStefan Ram
|   `- Re: operator precedenceStefan Ram
+* Re: operator precedenceChristian Hanné
|+* Re: operator precedenceKenny McCormack
||`* Re: operator precedenceKaz Kylheku
|| `- Shhh!!! (Was: operator precedence)Kenny McCormack
|`* Re: operator precedenceKeith Thompson
| `* Re: operator precedenceChristian Hanné
|  `* Re: operator precedencejames...@alumni.caltech.edu
|   +- Re: operator precedenceChristian Hanné
|   `* Re: operator precedenceKeith Thompson
|    `* Re: operator precedenceChristian Hanné
|     `* Re: operator precedenceKenny McCormack
|      `* Re: operator precedenceManfred
|       `- Re: operator precedenceDavid Brown
+* Re: operator precedenceGuillaume
|+* Re: operator precedenceStefan Ram
||+- Re: operator precedenceVir Campestris
||+* Re: operator precedenceStefan Ram
|||`- Re: operator precedenceDavid Brown
||+- Re: operator precedenceKenny McCormack
||`- Re: operator precedenceGuillaume
|+* Re: operator precedenceBen
||`* Re: operator precedenceGuillaume
|| `* Re: operator precedenceBen
||  +* Re: operator precedenceDavid Brown
||  |`* Re: operator precedenceBen
||  | `- Re: operator precedenceDavid Brown
||  `* Re: operator precedenceGuillaume
||   `* Re: operator precedenceBen
||    `* Re: operator precedenceDavid Brown
||     +* Re: operator precedenceKaz Kylheku
||     |`* Re: operator precedenceDavid Brown
||     | `* Re: operator precedenceKaz Kylheku
||     |  `- Re: operator precedenceDavid Brown
||     `* Re: operator precedenceJames Kuyper
||      `* Re: operator precedenceTim Rentsch
||       `- Re: operator precedencejames...@alumni.caltech.edu
|+- Re: operator precedenceBonita Montero
|`* Re: operator precedenceTim Rentsch
| +* Re: operator precedenceDavid Brown
| |`* Re: operator precedenceBen
| | `* Re: operator precedenceDavid Brown
| |  +* Re: operator precedenceBen
| |  |+* Re: operator precedenceDavid Brown
| |  ||`* Re: operator precedenceSams Lara
| |  || `* Re: operator precedenceDavid Brown
| |  ||  `* Re: operator precedenceBen
| |  ||   `* Re: operator precedenceDavid Brown
| |  ||    `* Re: operator precedenceBen
| |  ||     +* Re: operator precedenceDavid Brown
| |  ||     |+* Re: operator precedenceGiovanni
| |  ||     ||+* Re: operator precedenceDavid Brown
| |  ||     |||`- Re: operator precedenceMalcolm McLean
| |  ||     ||`- Re: operator precedenceStefan Ram
| |  ||     |`* Re: operator precedenceBen
| |  ||     | `* Re: operator precedenceDavid Brown
| |  ||     |  +* Re: operator precedenceDan Purgert
| |  ||     |  |`* Re: operator precedenceStefan Ram
| |  ||     |  | `- Re: operator precedenceDan Purgert
| |  ||     |  +- Re: operator precedenceBen
| |  ||     |  `* Re: operator precedenceRichard Harnden
| |  ||     |   `- Re: operator precedenceDavid Brown
| |  ||     `* Re: operator precedenceKaz Kylheku
| |  ||      `* Re: operator precedenceDavid Brown
| |  ||       +* Re: operator precedenceMalcolm McLean
| |  ||       |`- Re: operator precedenceDavid Brown
| |  ||       `* Re: operator precedenceJames Kuyper
| |  ||        `- Re: operator precedenceDavid Brown
| |  |`* Re: operator precedencebart c
| |  | +- Re: operator precedenceBen
| |  | `- Re: operator precedenceDavid Brown
| |  `- Re: operator precedenceÖö Tiib
| `* Re: operator precedenceScott Lurndal
|  `* Re: operator precedenceBen
|   `- Re: operator precedenceTim Rentsch
`- Re: operator precedenceTim Rentsch

Pages:1234
Shhh!!! (Was: operator precedence)

<t31bo8$2psod$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21148&group=comp.lang.c#21148

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Shhh!!! (Was: operator precedence)
Date: Mon, 11 Apr 2022 13:51:04 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t31bo8$2psod$1@news.xmission.com>
References: <thought-20220408125437@ram.dialup.fu-berlin.de> <t2uru3$1isf$1@gioia.aioe.org> <t2utnn$2om55$1@news.xmission.com> <20220410094247.215@kylheku.com>
Injection-Date: Mon, 11 Apr 2022 13:51:04 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2945805"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 11 Apr 2022 13:51 UTC

In article <20220410094247.215@kylheku.com>,
Kaz Kylheku <480-992-1380@kylheku.com> wrote:
....
>> How about Fortran? Or Perl?
>>
>> I.e., if you're going to suggest other, unrelated languages, why not go for
>> the sky?
>
>C++ is not an unrelated language; where you have C++, it is very well

Shhhh!!! They'll hear you!

(Whispers conspiratorially) Yes, you know that, and I know that, but they
don't. In fact, this newsgroup has long ago severed its connection to
reality.

In the dogma of this newsgroup, C++ is an entirely unrelated language, that
is as much off-topic here as any other language (other than C, of course).

You know. How they always make their little snide comments about "3 doors
down, past the water cooler, da da da..."

--
The people who tell us to be proud of the white race are the ones who make
us the most embarrassed by it.

Re: operator precedence

<t31bs0$2psod$2@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21149&group=comp.lang.c#21149

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 11 Apr 2022 13:53:04 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t31bs0$2psod$2@news.xmission.com>
References: <thought-20220408125437@ram.dialup.fu-berlin.de> <t2v61c$ej9$1@gioia.aioe.org> <precedence-20220410192504@ram.dialup.fu-berlin.de>
Injection-Date: Mon, 11 Apr 2022 13:53:04 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2945805"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 11 Apr 2022 13:53 UTC

In article <precedence-20220410192504@ram.dialup.fu-berlin.de>,
Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>Guillaume <message@bottle.org> writes:
>>Le 08/04/2022 14:00, Stefan Ram a crit:
>>>Recently, I wrote:
>>>board & 1 << row * COLS + col
>>If I saw this coming from someone in my team, I would probably fire them. =)
>
> I find it cute when programming witlings write down their
> fantasies of power. =)
>
>

Well put. My initial reaction to that guy was simpler. Was simply "As if
you ever led anything..."

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Seneca

Re: operator precedence

<t31sei$181t$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21151&group=comp.lang.c#21151

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!MJfzOZFZvtBCOkfnmkw/6g.user.46.165.242.75.POSTED!not-for-mail
From: mess...@bottle.org (Guillaume)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 11 Apr 2022 20:36:00 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t31sei$181t$1@gioia.aioe.org>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org>
<precedence-20220410192504@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="41021"; posting-host="MJfzOZFZvtBCOkfnmkw/6g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Content-Language: fr
X-Notice: Filtered by postfilter v. 0.9.2
 by: Guillaume - Mon, 11 Apr 2022 18:36 UTC

Le 10/04/2022 à 20:25, Stefan Ram a écrit :
> Guillaume <message@bottle.org> writes:
>> Le 08/04/2022 à 14:00, Stefan Ram a écrit :
>>> Recently, I wrote:
>>> board & 1 << row * COLS + col
>> If I saw this coming from someone in my team, I would probably fire them. =)
>
> I find it cute when programming witlings write down their
> fantasies of power. =)

I find it cute when some people get all worked up when they see a post
that is telling them that what they thought was all smart and skilled
was probably not a good idea, and focus on the unimportant humor part
while carefully ignoring the rest. :)

Re: operator precedence

<t31tda$1ohm$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21152&group=comp.lang.c#21152

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!MJfzOZFZvtBCOkfnmkw/6g.user.46.165.242.75.POSTED!not-for-mail
From: mess...@bottle.org (Guillaume)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 11 Apr 2022 20:52:24 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t31tda$1ohm$1@gioia.aioe.org>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="57910"; posting-host="MJfzOZFZvtBCOkfnmkw/6g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Content-Language: fr
X-Notice: Filtered by postfilter v. 0.9.2
 by: Guillaume - Mon, 11 Apr 2022 18:52 UTC

Le 10/04/2022 à 21:34, Ben a écrit :
> Guillaume <message@bottle.org> writes:
>
>> Le 08/04/2022 à 14:00, Stefan Ram a écrit :
>>> Recently, I wrote:
>>> board & 1 << row * COLS + col
>>
>> If I saw this coming from someone in my team, I would probably fire
>> them. =)
>
> Why is this such a common trope? I doubt any country has such poor
> employment protection that anyone could be fired for such a thing so I
> assume it's just a rhetorical device to say "I really care about this
> issue", but surely there are other ways to do that without being so
> Donal^H^H^H^H Alan Sugar about it.

Come on. I thought the smiley would convey the idea that it was
tongue-in-cheek, but apparently not. So yeah for those taking everything
literally, this was just a humorous way of showing a strong disagreement.

>> The readability rule that applies here is, if you need more than a few
>> seconds figuring out what a given statement exactly does, and may have
>> to even open the C standard to make sure, then it's badly
>> written. Rewrite it.
>
> The trouble with this (since I don't think you literally mean "you"
> here) is who is the typical reader? Do you aim for the lowest common
> denominator, or something in the middle? Does is vary by team? If it's
> a C compiler project, might you assume a higher standard of
> comprehension?

Readability, and trying to avoid hard-to-spot errors goes beyond being
skilled and knowing grammars by heart. It's not a matter of being good
or bad. For insance, indentation and whitespace are basically useless in
C, but they help readability quite a bit, even if you are an expert in
the language.

Regarding operator precedence, this is exactly covered by rule 12.1 of
MISRA-C:2012. "Limited dependence should be placed on operator
precedence rules in expressions"
It describes with examples what is what is not compliant.
While a number of MISRA-C rules can look "too much" to many, including
myself, I think that would be a good start here regarding this issue.

And whether you consider those guidelines in general to "aim for the
lowest common denominator" is debatable. The fact one may be convinced
to know better than those guidelines is also highly questionable.

Similar rules can be seen in other similar standards/coding guidelines.
Apparently no one that answered here have ever ahd to deal with any of
those, otherwise what I said would probably sound pretty obvious.

Re: operator precedence

<730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21153&group=comp.lang.c#21153

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a0c:8e0b:0:b0:435:1779:7b22 with SMTP id v11-20020a0c8e0b000000b0043517797b22mr28622007qvb.63.1649704365820;
Mon, 11 Apr 2022 12:12:45 -0700 (PDT)
X-Received: by 2002:a05:620a:28cc:b0:67d:b5f0:8d49 with SMTP id
l12-20020a05620a28cc00b0067db5f08d49mr684790qkp.100.1649704365648; Mon, 11
Apr 2022 12:12:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 11 Apr 2022 12:12:45 -0700 (PDT)
In-Reply-To: <t30jdp$1h9g$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=108.48.119.9; posting-account=Ix1u_AoAAAAILVQeRkP2ENwli-Uv6vO8
NNTP-Posting-Host: 108.48.119.9
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2uru3$1isf$1@gioia.aioe.org> <87a6csocyx.fsf@nosuchdomain.example.com> <t30jdp$1h9g$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com>
Subject: Re: operator precedence
From: jameskuy...@alumni.caltech.edu (james...@alumni.caltech.edu)
Injection-Date: Mon, 11 Apr 2022 19:12:45 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1599
 by: james...@alumni.calt - Mon, 11 Apr 2022 19:12 UTC

On Monday, April 11, 2022 at 2:56:11 AM UTC-4, Christian Hanné wrote:
> C++ allows defining your own operator-predence priorities since C++17.

12.6p7: "It is not possible to change the precedence, grouping, or number of operands of operators."

Re: operator precedence

<878rsb4b8g.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21154&group=comp.lang.c#21154

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 11 Apr 2022 21:27:11 +0100
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <878rsb4b8g.fsf@bsb.me.uk>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="6c4ca32cd487f3859fc70aa54a6c7562";
logging-data="19504"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r4IGslWBfWy5Ydru/fjRDAJGO1Jj5JM4="
Cancel-Lock: sha1:0H/DrbdyHhF8YUZ4qH6iYDLqQnI=
sha1:O3eV3+2mIKIkkZ90e2DGFd+upBo=
X-BSB-Auth: 1.bde45a0f52dbc0e72f67.20220411212711BST.878rsb4b8g.fsf@bsb.me.uk
 by: Ben - Mon, 11 Apr 2022 20:27 UTC

Guillaume <message@bottle.org> writes:

> Le 10/04/2022 à 21:34, Ben a écrit :
>> Guillaume <message@bottle.org> writes:
>>
>>> Le 08/04/2022 à 14:00, Stefan Ram a écrit :
>>>> Recently, I wrote:
>>>> board & 1 << row * COLS + col
>>>
>>> If I saw this coming from someone in my team, I would probably fire
>>> them. =)
>> Why is this such a common trope? I doubt any country has such poor
>> employment protection that anyone could be fired for such a thing so I
>> assume it's just a rhetorical device to say "I really care about this
>> issue", but surely there are other ways to do that without being so
>> Donal^H^H^H^H Alan Sugar about it.
>
> Come on. I thought the smiley would convey the idea that it was
> tongue-in-cheek, but apparently not. So yeah for those taking
> everything literally, this was just a humorous way of showing a strong
> disagreement.

OK. My news client turns emoticons into smilies but it does not know
about =) so I missed it. In fact I've never seen =) before.

The way people use happy faces (I think that's what =) is) these days, I
would use ;) to suggest I'm not serious. Otherwise it could mean you'd
fire them and smile all the way to HR with their P45!

>>> The readability rule that applies here is, if you need more than a few
>>> seconds figuring out what a given statement exactly does, and may have
>>> to even open the C standard to make sure, then it's badly
>>> written. Rewrite it.
>> The trouble with this (since I don't think you literally mean "you"
>> here) is who is the typical reader? Do you aim for the lowest common
>> denominator, or something in the middle? Does is vary by team? If it's
>> a C compiler project, might you assume a higher standard of
>> comprehension?
>
> Readability, and trying to avoid hard-to-spot errors goes beyond being
> skilled and knowing grammars by heart. It's not a matter of being good
> or bad. For insance, indentation and whitespace are basically useless
> in C, but they help readability quite a bit, even if you are an expert
> in the language.

Of course. I didn't really want to open up the discussion too wide, so
I was trying to ask only about those elements that related to what the
reader can be expected to know.

> Regarding operator precedence, this is exactly covered by rule 12.1 of
> MISRA-C:2012. "Limited dependence should be placed on operator
> precedence rules in expressions" It describes with examples what is
> what is not compliant. While a number of MISRA-C rules can look "too
> much" to many, including myself, I think that would be a good start
> here regarding this issue.

I shall have to remain in the dark then about what you consider a good
start because the quote "Limited dependence should be placed on operator
precedence rules in expressions" I think MISRA costs money.

> And whether you consider those guidelines in general to "aim for the
> lowest common denominator" is debatable. The fact one may be convinced
> to know better than those guidelines is also highly questionable.

There are other considerations. Sometimes respecting your team's
ability to get it right without a thick tome of guidelines works
better.

> Similar rules can be seen in other similar standards/coding
> guidelines. Apparently no one that answered here have ever ahd to deal
> with any of those, otherwise what I said would probably sound pretty
> obvious.

I have. I hated it. I looked for another job where I was trusted to
write readable code.

--
Ben.

Re: operator precedence

<t342o0$d1q$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21160&group=comp.lang.c#21160

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!YgKMkT8Hbhw8vNatTmzQ/w.user.46.165.242.75.POSTED!not-for-mail
From: the.ha...@gmail.com (Christian Hanné)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Tue, 12 Apr 2022 16:35:52 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t342o0$d1q$1@gioia.aioe.org>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2uru3$1isf$1@gioia.aioe.org> <87a6csocyx.fsf@nosuchdomain.example.com>
<t30jdp$1h9g$1@gioia.aioe.org>
<730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="13370"; posting-host="YgKMkT8Hbhw8vNatTmzQ/w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: de-DE
 by: Christian Hanné - Tue, 12 Apr 2022 14:35 UTC

Am 11.04.2022 um 21:12 schrieb james...@alumni.caltech.edu:
> On Monday, April 11, 2022 at 2:56:11 AM UTC-4, Christian Hanné wrote:
>> C++ allows defining your own operator-predence priorities since C++17.
>
> 12.6p7: "It is not possible to change the precedence, grouping, or number of operands of operators."

That's not from the standard.

Re: operator precedence

<87wnfufaow.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21162&group=comp.lang.c#21162

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Tue, 12 Apr 2022 10:55:43 -0700
Organization: None to speak of
Lines: 17
Message-ID: <87wnfufaow.fsf@nosuchdomain.example.com>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2uru3$1isf$1@gioia.aioe.org>
<87a6csocyx.fsf@nosuchdomain.example.com>
<t30jdp$1h9g$1@gioia.aioe.org>
<730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="f353463c21bd7ec93c74cbc7ba8abe1b";
logging-data="1726"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/422wGBZEVEK1LlhoQw9gB"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:NEB9qfHmuJhaEPxZdzG200uE7iM=
sha1:+pflTBrh9s7E4kJJSRgijcY3Tuw=
 by: Keith Thompson - Tue, 12 Apr 2022 17:55 UTC

"james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> writes:
> On Monday, April 11, 2022 at 2:56:11 AM UTC-4, Christian Hanné wrote:
>> C++ allows defining your own operator-predence priorities since C++17.
>
> 12.6p7: "It is not possible to change the precedence, grouping, or
> number of operands of operators."

For clarity, if you cite a section of the standard, I suggest mentioning
which edition and/or including the name of the section, in this case
[over.oper]. The sentence you quoted does appear in every edition of
the standard going back to 1998, but the section number varies. (In
C++17 it's 16.5p6.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: operator precedence

<t370s8$1ntv$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21194&group=comp.lang.c#21194

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!YgKMkT8Hbhw8vNatTmzQ/w.user.46.165.242.75.POSTED!not-for-mail
From: the.ha...@gmail.com (Christian Hanné)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Wed, 13 Apr 2022 19:22:25 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t370s8$1ntv$1@gioia.aioe.org>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2uru3$1isf$1@gioia.aioe.org> <87a6csocyx.fsf@nosuchdomain.example.com>
<t30jdp$1h9g$1@gioia.aioe.org>
<730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com>
<87wnfufaow.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="57279"; posting-host="YgKMkT8Hbhw8vNatTmzQ/w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: de-DE
 by: Christian Hanné - Wed, 13 Apr 2022 17:22 UTC

Am 12.04.2022 um 19:55 schrieb Keith Thompson:
> "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> writes:
>> On Monday, April 11, 2022 at 2:56:11 AM UTC-4, Christian Hanné wrote:
>>> C++ allows defining your own operator-predence priorities since C++17.
>>
>> 12.6p7: "It is not possible to change the precedence, grouping, or
>> number of operands of operators."
>
> For clarity, if you cite a section of the standard, I suggest mentioning
> which edition and/or including the name of the section, in this case
> [over.oper]. The sentence you quoted does appear in every edition of
> the standard going back to 1998, but the section number varies. (In
> C++17 it's 16.5p6.)

You're the liar I'm accused to be.
C++17 allows reassigning the operator precedence for certain statements.

Re: operator precedence

<t371s6$2sp0t$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21195&group=comp.lang.c#21195

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Wed, 13 Apr 2022 17:39:18 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t371s6$2sp0t$1@news.xmission.com>
References: <thought-20220408125437@ram.dialup.fu-berlin.de> <730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com> <87wnfufaow.fsf@nosuchdomain.example.com> <t370s8$1ntv$1@gioia.aioe.org>
Injection-Date: Wed, 13 Apr 2022 17:39:18 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3040285"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 13 Apr 2022 17:39 UTC

In article <t370s8$1ntv$1@gioia.aioe.org>,
Christian Hann <the.hanne@gmail.com> wrote:
>Am 12.04.2022 um 19:55 schrieb Keith Thompson:
>> "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> writes:
>>> On Monday, April 11, 2022 at 2:56:11 AM UTC-4, Christian Hann wrote:
>>>> C++ allows defining your own operator-predence priorities since C++17.
>>>
>>> 12.6p7: "It is not possible to change the precedence, grouping, or
>>> number of operands of operators."
>>
>> For clarity, if you cite a section of the standard, I suggest mentioning
>> which edition and/or including the name of the section, in this case
>> [over.oper]. The sentence you quoted does appear in every edition of
>> the standard going back to 1998, but the section number varies. (In
>> C++17 it's 16.5p6.)
>
>You're the liar I'm accused to be.
>C++17 allows reassigning the operator precedence for certain statements.

You are probably right. KT is (usually) full of shit, which is why I have
him in my "select file" - his stuff is always entertaining to read.

But you need to give a demo. Show us a small, complete, compilable C++
program, with the command(s) you used to compile it, and show a sample run
(that demonstrates the point you are claiming).

--
Mike Huckabee has yet to consciously uncouple from Josh Duggar.

Re: operator precedence

<t37378$ro8$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21196&group=comp.lang.c#21196

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Wed, 13 Apr 2022 20:02:14 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t37378$ro8$1@gioia.aioe.org>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com>
<87wnfufaow.fsf@nosuchdomain.example.com> <t370s8$1ntv$1@gioia.aioe.org>
<t371s6$2sp0t$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="28424"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Wed, 13 Apr 2022 18:02 UTC

On 4/13/2022 7:39 PM, Kenny McCormack wrote:
> In article <t370s8$1ntv$1@gioia.aioe.org>,
> Christian Hann <the.hanne@gmail.com> wrote:
>> Am 12.04.2022 um 19:55 schrieb Keith Thompson:
>>> "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> writes:
>>>> On Monday, April 11, 2022 at 2:56:11 AM UTC-4, Christian Hann wrote:
>>>>> C++ allows defining your own operator-predence priorities since C++17.
>>>>
>>>> 12.6p7: "It is not possible to change the precedence, grouping, or
>>>> number of operands of operators."
>>>
>>> For clarity, if you cite a section of the standard, I suggest mentioning
>>> which edition and/or including the name of the section, in this case
>>> [over.oper]. The sentence you quoted does appear in every edition of
>>> the standard going back to 1998, but the section number varies. (In
>>> C++17 it's 16.5p6.)
>>
>> You're the liar I'm accused to be.
>> C++17 allows reassigning the operator precedence for certain statements.
>
> You are probably right.

No, he is not. The standard is very clear on this point.
I'm surprised of how much feed the troll is getting from this subthread.
Maybe it has to do with being c.l.c. and the C++ standard is less known
in this context.

Re: operator precedence

<t38b8g$pv1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21216&group=comp.lang.c#21216

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: operator precedence
Date: Thu, 14 Apr 2022 01:25:34 -0400
Organization: A noiseless patient Spider
Lines: 220
Message-ID: <t38b8g$pv1$1@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2plh1$6fk$1@dont-email.me>
<chine.bleu-08FB27.10100008042022@reader.eternal-september.org>
<dd5d5d14-9d59-407d-a8ac-fb37aad2c711n@googlegroups.com>
<t2v6o3$gec$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 14 Apr 2022 05:25:36 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="fa3e78f11f0f9ef37c80fba2b7c1f018";
logging-data="26593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pvByezQKNktCZFX9vOekijlzDvODEkbQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:FzD2WFj7OssnYHrkMQNslHPENEI=
In-Reply-To: <t2v6o3$gec$1@dont-email.me>
Content-Language: en-US
 by: James Kuyper - Thu, 14 Apr 2022 05:25 UTC

I just noticed that the e-mail you're responding to was a response by me
to a message on the comp.lang.c++, which accidentally got posted to
comp.lang.c instead.
So that the folks in c.l.c know what happened to this thread, I'm
including them in this message. However, I've set Reply-To: to
comp.lang.c++ only.

I apologize for the delay in my response. My 7-year-old kids have been
on spring break virtually the entire time I've been working on this
response, and it would have taken me a fair amount of time to figure
this out even without that distraction.

On 4/10/22 14:13, Andrey Tarasevich wrote:
> On 4/8/2022 8:46 PM, james...@alumni.caltech.edu wrote:
>> On Friday, April 8, 2022 at 1:10:22 PM UTC-4, Siri Cruise wrote:
>>> In article <t2plh1$6fk$1...@dont-email.me>,
>> ...
>>> For a time I was thinking of Fortran rules where parentheses can
>>> affect order of evaluation. Once I got that clear that
>>> parentheses in C have no effect on generated code.
>>
>> Parentheses don't directly affect order of evaluation. They do,
>> however, do something far more important - they can change which
>> expressions are sub-expressions of other expressions, which has a
>> big effect on the generated code. In `a + b*c`, `b*c` is the right
>> operand of the `+` operator; in `(a + b)*c`, `a+b` is the left operand
>> of the `*` operator.
>>
>> As a result, parentheses do indirectly affect the order of evaluation,
>> since evaluations of sub-expressions are sequenced before evaluation
>> of the expression they are part of. That is not enough to determine
>> the order of evaluation, but it does constrain the order.
>
> This is lazy wording, which makes it incorrect. The "subexpression
> before expression" sequencing you mention does not cover side effects.

I was sloppy with the wording because I've cited the corresponding
clause from the standard several times recently, and have gotten
tired of citing it exactly.

> It only covers value computations. What you are trying to say is what
> the standard formulates as:
>
> 6.5 Expressions
> 1 [...] The value computations of the operands of an operator are
> sequenced before the value computation of the result of the operator.
>
> Note the specific reference to *value computations*. That is the correct
> wording.
>
> You can put as many parentheses in your expression as you want, they
> won't have any effect on sequencing of side effects. ...

You are right about 6.5p1 only directly constraining the sequencing of
value computation. It's not quite as trivial as the fact that it doesn't
mention side-effects - I'll explain the complications below. However, I
was wrong to say that parentheses can effect the sequencing of side
effects because of that clause. They can effect the sequencing of side
effects, but not for that reason.

> ... So no, you cannot
> just claim that parentheses introduce a "sequenced before" ordering
> without explicitly stating that this ordering applies to value
> computations only.
>
> And, once again, whatever ordering your parentheses might introduce,
> they introduce it in an Abstract C Machine. Until you somehow trace/tie
> that ordering to observable behavior, it won't have any connection to
> the behavior of your specific real-life compiler and your specific
> real-life code.

There's three different kinds of observable behavior:

"— Volatile accesses to objects are evaluated strictly according to the
rules of the abstract machine.
— At program termination, all data written into files shall be identical
to the result that execution of the program according to the abstract
semantics would have produced.
— The input and output dynamics of interactive devices shall take place
as specified in 7.21.3." (5.1.2.3p6)

Virtually any change to the code that can change the behavior of the
abstract machine can trivially be turned into observable behavior by
inserting volatile accesses, writes to files, or input/output to
interactive devices in appropriate locations. I'll be using calls to
putchar() and printf() for that purpose down below.

There's three fundamental kinds of side effects: "Accessing a volatile
object, modifying an object, modifying a file ...". There's one derived
kind of side effect: "calling a function that does any of those
operations." (5.1.2.3p2).

I'm going to ignore volatile accesses, since "What constitutes an access
to an object that has volatile-qualified type is
implementation-defined." (6.7.3), making it impossible to produce an
example that's portably guaranteed to demonstrate my point. Also, while
"volatile accesses" are officially "observable behavior" as far as the
standard is concerned, they do not necessarily constitute "behavior
which can be observed" on any particular system.

What I was thinking of was the fact that "The presence of a sequence
point between the evaluation of expressions A and B implies that every
value computation and side effect associated with A is sequenced before
every value computation and side effect associated with B." (5.1.2.3p3).

Therefore, anything that changes the sequencing of two value
computations will also change the sequencing of their corresponding
side-effects, so long as there's a sequence point between them (either
before or after the change).

However, I didn't think that through. Every single construct that
introduces a sequence point between two expressions also mandates the
sequence of those two expressions, and usually requires that an
expression that is textually to the left of the operator within same
full-expression be sequenced before an expression that is textually on
the right in that same full-expression. Inserting parentheses won't
change that textual order. Sequence points do not generally come between
a sub-expression and evaluation of the expression itself. Finally, most
of the expressions that have associated sequence points don't cause
side-effects.

However, parentheses can still change the sequencing requirements,
because they change which expressions are sub-expressions of other
expressions. As a result, they can change which expressions are
sequenced by any given sequence point.

For example, if all of the following are true:
1. E1, E2, E3, and E4 are expressions that might have side-effects

2. OP1 and OP3 are operators with associated sequence point

3. OP2 is an operator with no associated sequence point

4. The following expressions, which differ only in the placement of
parenthesis:
A: (E1 OP1 E2) OP2 (E3 OP3 E4
B: E1 OP1 (E2 OP2 E3) OP3 E4
are syntactically valid, with no constraint violation or undefined behavior

Then expression A and expression B impose different sequencing
requirements on the side-effects of those expressions:

Expression A: E1 must be evaluated before E2, E3 must be evaluated
before E4.
Expression B: E1 must be evaluated first, E4 must be evaluated last.

Neither expression imposes any other requirements on the sequencing of
side effects. As a result, the order E3 E4 E1 E2 is allowed by
expression A, but not by expression B.

Specific example:

A: ( putchar('a') && putchar('b') ) & ( putchar('c') && putchar('d') );
B: putchar('a') && ( putchar('b') & putchar('c') ) && putchar('d');

"bdac" is a possible output from expression A, but not from expression B.

In that example, changing parentheses merely changed sequenced
expressions into unsequenced expressions (or vice-versa). I'd hoped I
could find an example that reversed the required sequence of two
side-effects, but that turns out to be more difficult. However, there is
one (and only one) exception to several of the generalizations I made up
above:
1. Function calls are the only kinds of expressions where one of the
sequence points associated with function calls does separate a
side effects of a sub-expression from the side effects of the main
expression.
2. Function calls are the only kinds of expressions that have a sequence
point that directly constrains the sequencing of code that is not part
of the same full expression, namely the code in the function body.
3. Function calls are the only kinds of expressions that have an
associated sequence point and can qualify as side effects.

Therefore, I can reverse the sequencing using parentheses in the
following example.

#include <stdio.h>
// pointer to a generic function type used as return type.
typedef void gfunc(void);
// The actual type of the functions below.
typedef gfunc* (afunc)(void);

afunc *strange;
static gfunc* up(void) {
printf("up:strange %s up\n", strange == up ? "==" : "!=");
// Note that this cast is absolutely essential. Attempting to declare a
// function that returns a pointer to a function with that function's
// own type results in infinite recursion.
return (gfunc*)up;
}
Click here to read the complete article

Re: operator precedence

<t38bka$pv1$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21217&group=comp.lang.c#21217

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Thu, 14 Apr 2022 01:31:54 -0400
Organization: A noiseless patient Spider
Lines: 213
Message-ID: <t38bka$pv1$3@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2plh1$6fk$1@dont-email.me>
<chine.bleu-08FB27.10100008042022@reader.eternal-september.org>
<dd5d5d14-9d59-407d-a8ac-fb37aad2c711n@googlegroups.com>
<t2v6o3$gec$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 14 Apr 2022 05:31:55 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="fa3e78f11f0f9ef37c80fba2b7c1f018";
logging-data="26593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EpPl/L28VD+RGJHPb2hrPDZaX34D0nCM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:vrOyqlHEshofn4GpKqYHpdMZk6I=
In-Reply-To: <t2v6o3$gec$1@dont-email.me>
Content-Language: en-US
 by: James Kuyper - Thu, 14 Apr 2022 05:31 UTC

I apologize for the delay in my response. My 7-year-old kids have been
on spring break virtually the entire time I've been working on this
response, and it would have taken me a fair amount of time to figure
this out even without that distraction.

On 4/10/22 14:13, Andrey Tarasevich wrote:
> On 4/8/2022 8:46 PM, james...@alumni.caltech.edu wrote:
>> On Friday, April 8, 2022 at 1:10:22 PM UTC-4, Siri Cruise wrote:
>>> In article <t2plh1$6fk$1...@dont-email.me>,
>> ...
>>> For a time I was thinking of Fortran rules where parentheses can
>>> affect order of evaluation. Once I got that clear that
>>> parentheses in C have no effect on generated code.
>>
>> Parentheses don't directly affect order of evaluation. They do,
>> however, do something far more important - they can change which
>> expressions are sub-expressions of other expressions, which has a
>> big effect on the generated code. In `a + b*c`, `b*c` is the right
>> operand of the `+` operator; in `(a + b)*c`, `a+b` is the left operand
>> of the `*` operator.
>>
>> As a result, parentheses do indirectly affect the order of evaluation,
>> since evaluations of sub-expressions are sequenced before evaluation
>> of the expression they are part of. That is not enough to determine
>> the order of evaluation, but it does constrain the order.
>
> This is lazy wording, which makes it incorrect. The "subexpression
> before expression" sequencing you mention does not cover side effects.

I was sloppy with the wording because I've cited the corresponding
clause from the standard several times recently, and have gotten
tired of citing it exactly.

> It only covers value computations. What you are trying to say is what
> the standard formulates as:
>
> 6.5 Expressions
> 1 [...] The value computations of the operands of an operator are
> sequenced before the value computation of the result of the operator.
>
> Note the specific reference to *value computations*. That is the
> correct wording.
>
> You can put as many parentheses in your expression as you want, they
> won't have any effect on sequencing of side effects. ...

You are right about 6.5p1 only directly constraining the sequencing of
value computation. It's not quite as trivial as the fact that it doesn't
mention side-effects - I'll explain the complications below. However, I
was wrong to say that parentheses can effect the sequencing of side
effects because of that clause. They can effect the sequencing of side
effects, but not for that reason.

> ... So no, you cannot just claim that parentheses introduce a
> "sequenced before" ordering without explicitly stating that this
> ordering applies to value computations only.
>
> And, once again, whatever ordering your parentheses might introduce,
> they introduce it in an Abstract C Machine. Until you somehow
> trace/tie that ordering to observable behavior, it won't have any
> connection to the behavior of your specific real-life compiler and
> your specific real-life code.

There's three different kinds of observable behavior:

"— Volatile accesses to objects are evaluated strictly according to the
rules of the abstract machine.
— At program termination, all data written into files shall be identical
to the result that execution of the program according to the abstract
semantics would have produced.
— The input and output dynamics of interactive devices shall take place
as specified in 7.21.3." (5.1.2.3p6)

Virtually any change to the code that can change the behavior of the
abstract machine can trivially be turned into observable behavior by
inserting volatile accesses, writes to files, or input/output to
interactive devices in appropriate locations. I'll be using calls to
putchar() and printf() for that purpose down below.

There's three fundamental kinds of side effects: "Accessing a volatile
object, modifying an object, modifying a file ...". There's one derived
kind of side effect: "calling a function that does any of those
operations." (5.1.2.3p2).

I'm going to ignore volatile accesses, since "What constitutes an access
to an object that has volatile-qualified type is
implementation-defined." (6.7.3), making it impossible to produce an
example that's portably guaranteed to demonstrate my point. Also, while
"volatile accesses" are officially "observable behavior" as far as the
standard is concerned, they do not necessarily constitute "behavior
which can be observed" on any particular system.

What I was thinking of was the fact that "The presence of a sequence
point between the evaluation of expressions A and B implies that every
value computation and side effect associated with A is sequenced before
every value computation and side effect associated with B." (5.1.2.3p3).

Therefore, anything that changes the sequencing of two value
computations will also change the sequencing of their corresponding
side-effects, so long as there's a sequence point between them (either
before or after the change).

However, I didn't think that through. Every single construct that
introduces a sequence point between two expressions also mandates the
sequence of those two expressions, and usually requires that an
expression that is textually to the left of the operator within same
full-expression be sequenced before an expression that is textually on
the right in that same full-expression. Inserting parentheses won't
change that textual order. Sequence points do not generally come between
a sub-expression and evaluation of the expression itself. Finally, most
of the expressions that have associated sequence points don't cause
side-effects.

However, parentheses can still change the sequencing requirements,
because they change which expressions are sub-expressions of other
expressions. As a result, they can change which expressions are
sequenced by any given sequence point.

For example, if all of the following are true:
1. E1, E2, E3, and E4 are expressions that might have side-effects

2. OP1 and OP3 are operators with associated sequence point

3. OP2 is an operator with no associated sequence point

4. The following expressions, which differ only in the placement of
parenthesis:
A: (E1 OP1 E2) OP2 (E3 OP3 E4
B: E1 OP1 (E2 OP2 E3) OP3 E4
are syntactically valid, with no constraint violation or undefined behavior

Then expression A and expression B impose different sequencing
requirements on the side-effects of those expressions:

Expression A: E1 must be evaluated before E2, E3 must be evaluated
before E4.
Expression B: E1 must be evaluated first, E4 must be evaluated last.

Neither expression imposes any other requirements on the sequencing of
side effects. As a result, the order E3 E4 E1 E2 is allowed by
expression A, but not by expression B.

Specific example:

A: ( putchar('a') && putchar('b') ) & ( putchar('c') && putchar('d') );
B: putchar('a') && ( putchar('b') & putchar('c') ) && putchar('d');

"bdac" is a possible output from expression A, but not from expression B.

In that example, changing parentheses merely changed sequenced
expressions into unsequenced expressions (or vice-versa). I'd hoped I
could find an example that reversed the required sequence of two
side-effects, but that turns out to be more difficult. However, there is
one (and only one) exception to several of the generalizations I made up
above:
1. Function calls are the only kinds of expressions where one of the
sequence points associated with function calls does separate a
side effects of a sub-expression from the side effects of the main
expression.
2. Function calls are the only kinds of expressions that have a sequence
point that directly constrains the sequencing of code that is not part
of the same full expression, namely the code in the function body.
3. Function calls are the only kinds of expressions that have an
associated sequence point and can qualify as side effects.

Therefore, I can reverse the sequencing using parentheses in the
following example.

#include <stdio.h>
// pointer to a generic function type used as return type.
typedef void gfunc(void);
// The actual type of the functions below.
typedef gfunc* (afunc)(void);

afunc *strange;
static gfunc* up(void) {
printf("up:strange %s up\n", strange == up ? "==" : "!=");
// Note that this cast is absolutely essential. Attempting to declare a
// function that returns a pointer to a function with that function's
// own type results in infinite recursion.
return (gfunc*)up;
} static gfunc* down(void) {
printf("down:strange %s down\n", strange == down ? "==" : "!=");
return (gfunc*)down;
} afunc *strange = up;

int main(void)
{ strange = (afunc*)down(); // 1
printf("main:strange %s down\n", strange == down ? "==" : "!=");


Click here to read the complete article
Re: operator precedence

<t38u5c$l49$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21224&group=comp.lang.c#21224

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Thu, 14 Apr 2022 12:48:12 +0200
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <t38u5c$l49$1@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<730edf55-20c6-473d-80e4-0d72edf3f48fn@googlegroups.com>
<87wnfufaow.fsf@nosuchdomain.example.com> <t370s8$1ntv$1@gioia.aioe.org>
<t371s6$2sp0t$1@news.xmission.com> <t37378$ro8$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 14 Apr 2022 10:48:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e9b65ca3f6114005f4fcc1fdc6c86675";
logging-data="21641"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/P94F48JYv0tSHr4VNNWFzLMT6bOHlk7M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:OJznKukegzMudJjMR9MpHA9Ow+I=
In-Reply-To: <t37378$ro8$1@gioia.aioe.org>
Content-Language: en-GB
 by: David Brown - Thu, 14 Apr 2022 10:48 UTC

On 13/04/2022 20:02, Manfred wrote:
> On 4/13/2022 7:39 PM, Kenny McCormack wrote:
>> In article <t370s8$1ntv$1@gioia.aioe.org>,
>> Christian Hann  <the.hanne@gmail.com> wrote:
>>> Am 12.04.2022 um 19:55 schrieb Keith Thompson:
>>>> "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> writes:
>>>>> On Monday, April 11, 2022 at 2:56:11 AM UTC-4, Christian Hann wrote:
>>>>>> C++ allows defining your own operator-predence priorities since
>>>>>> C++17.
>>>>>
>>>>> 12.6p7: "It is not possible to change the precedence, grouping, or
>>>>> number of operands of operators."
>>>>
>>>> For clarity, if you cite a section of the standard, I suggest
>>>> mentioning
>>>> which edition and/or including the name of the section, in this case
>>>> [over.oper].  The sentence you quoted does appear in every edition of
>>>> the standard going back to 1998, but the section number varies.  (In
>>>> C++17 it's 16.5p6.)
>>>
>>> You're the liar I'm accused to be.
>>> C++17 allows reassigning the operator precedence for certain statements.
>>
>> You are probably right.
>
> No, he is not. The standard is very clear on this point.
> I'm surprised of how much feed the troll is getting from this subthread.
> Maybe it has to do with being c.l.c. and the C++ standard is less known
> in this context.

Some of Hanné's trolling is subtle enough that some people might be
fooled by it, so it is helpful to correct it. Unfortunately, that has
the side-effect of encouraging him.

Re: operator precedence

<t38vlr$hr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21225&group=comp.lang.c#21225

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Thu, 14 Apr 2022 13:14:04 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <t38vlr$hr$1@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org>
<precedence-20220410192504@ram.dialup.fu-berlin.de>
<precedence-20220411141849@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Apr 2022 11:14:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d8bd17f35f358fe66ceace32ad3c9d5b";
logging-data="571"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1942d7hzYqroZAJqeIHTA9c8F0yVmpbbcY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:qI8Z0gYxyhXOq0Cb6thB3U9JenY=
In-Reply-To: <precedence-20220411141849@ram.dialup.fu-berlin.de>
Content-Language: en-GB
 by: David Brown - Thu, 14 Apr 2022 11:14 UTC

On 11/04/2022 15:27, Stefan Ram wrote:
> C is a language with some subtleties, and programming often
> is somewhat complex overall. If you don't trust a C programmer
> to even get an expression as simple as "a & b << c + 1",
> how is he supposed to get more subtle things right?
>

A programmer should spend their time and effort learning the /important/
things - not the frivolities of how to write expressions that are
difficult to read. Details of the presidencies of rarely-used operators
are irrelevant in most coding. Any effort spent learning these details
is wasted. Any code written that relies on such knowledge is wasted
effort by the programmer, and more wasted effort by the reader. The
programmer is supposed to get the subtle things right precisely because
he or she isn't trying to show off their pointless knowledge of this
kind of thing. I want programmers that are smart, not smart-arse.

Guillaume and Vir are right (in my opinion). If someone in the
programming team writes an expression like the one above, it's an
opportunity for learning and to teach the newbie good coding practices.
If the guilty party is not a newbie, it's time for them to re-learn how
to program as part of a team. If they won't re-learn, it's time to
question if they should be part of the team at all.

Re: operator precedence

<t39149$brl$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21226&group=comp.lang.c#21226

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Thu, 14 Apr 2022 13:38:49 +0200
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <t39149$brl$1@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 14 Apr 2022 11:38:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8ca88fd922bc2c5d7b2ffd96a47536a6";
logging-data="12149"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+q+fya1vceMKFC/M9ZqlskidPKTZlFJ6o="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:NkDJCHEhgV+E3ngH/Y4ZBl4x7Es=
In-Reply-To: <878rsb4b8g.fsf@bsb.me.uk>
Content-Language: en-GB
 by: David Brown - Thu, 14 Apr 2022 11:38 UTC

On 11/04/2022 22:27, Ben wrote:
> Guillaume <message@bottle.org> writes:
>

>> Regarding operator precedence, this is exactly covered by rule 12.1 of
>> MISRA-C:2012. "Limited dependence should be placed on operator
>> precedence rules in expressions" It describes with examples what is
>> what is not compliant. While a number of MISRA-C rules can look "too
>> much" to many, including myself, I think that would be a good start
>> here regarding this issue.
>
> I shall have to remain in the dark then about what you consider a good
> start because the quote "Limited dependence should be placed on operator
> precedence rules in expressions" I think MISRA costs money.
>

Last time I bought a MISRA standard, it was £10, and the pdf I got had
my name watermarked on every page. This has always seemed an incredibly
silly price - companies that need to use MISRA would pay even a hundred
times as much (though they'd be annoyed about it) because they have no
choice. Having a price at all means the document has to be purchased -
and the bureaucracy of purchase orders, bill approval and all the rest
will generally cost a company far more than the £10 price.

One complication with discussions like these is that they are generally
taken out of context. In different types of coding, different
expressions or code patterns turn up. Familiarity is a big factor in
reading or writing correct code, and heavily influences appropriate
guidelines for a particular type of work.

Another complication that has been mentioned is the target audience.
Are they the kind of C programmer that has read and re-read the C
standards? Are they programmers who have had extensive training in
dedicated C course? Are they hardware engineers, mathematicians, or
others with strong technical skills and education, but only a smattering
of C knowledge? Are they coming from other programming languages? Are
they people who are not yet born, who will be looking at this code 25
years from now?

>> And whether you consider those guidelines in general to "aim for the
>> lowest common denominator" is debatable. The fact one may be convinced
>> to know better than those guidelines is also highly questionable.
>
> There are other considerations. Sometimes respecting your team's
> ability to get it right without a thick tome of guidelines works
> better.
>
>> Similar rules can be seen in other similar standards/coding
>> guidelines. Apparently no one that answered here have ever ahd to deal
>> with any of those, otherwise what I said would probably sound pretty
>> obvious.
>
> I have. I hated it. I looked for another job where I was trusted to
> write readable code.
>

I have had to write code to MISRA standards a couple of times. Some
aspects were fine, others were annoying, but it is not the worst I have
dealt with. Maintaining code written with no thought or regard to
readability, or by smart-arse programmers, is worse IME. A coding
standard does not force people to write clear code, nor does a lack of a
standard imply code is not clear. But standards can limit some of the
worst aspects of code.

Re: operator precedence

<87ilrbu82a.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21228&group=comp.lang.c#21228

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Thu, 14 Apr 2022 14:07:57 +0100
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <87ilrbu82a.fsf@bsb.me.uk>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t39149$brl$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="d24b48f9c0b0cf8c127841564518bd44";
logging-data="15678"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ptBdpwHI4z6WMRBIFXb6WZI2MrnYDr1M="
Cancel-Lock: sha1:fh76Irzg6NjcR/Q3FcaSl9jd7pM=
sha1:Mk1kFV78zkYRH6zAny+QknG0NKI=
X-BSB-Auth: 1.7ebd81a17970948c56bf.20220414140757BST.87ilrbu82a.fsf@bsb.me.uk
 by: Ben - Thu, 14 Apr 2022 13:07 UTC

David Brown <david.brown@hesbynett.no> writes:

> I have had to write code to MISRA standards a couple of times. Some
> aspects were fine, others were annoying, but it is not the worst I
> have dealt with. Maintaining code written with no thought or regard
> to readability, or by smart-arse programmers, is worse IME. A coding
> standard does not force people to write clear code, nor does a lack of
> a standard imply code is not clear. But standards can limit some of
> the worst aspects of code.

Compared to many here, my experience is limited, but I did not get that
impression from that limited experience. Coding standards are almost
always about the surface syntax, and all the headaches I remember having
with other people's code had nothing whatsoever to do with the surface
syntax.

--
Ben.

Re: operator precedence

<t3c9vm$d1r$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21244&group=comp.lang.c#21244

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!xxg7gqfdWlnbkv8rBcaxvQ.user.46.165.242.75.POSTED!not-for-mail
From: mess...@bottle.org (Guillaume)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Fri, 15 Apr 2022 19:28:17 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t3c9vm$d1r$1@gioia.aioe.org>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="13371"; posting-host="xxg7gqfdWlnbkv8rBcaxvQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: fr
 by: Guillaume - Fri, 15 Apr 2022 17:28 UTC

Le 11/04/2022 à 22:27, Ben a écrit :
> I shall have to remain in the dark then about what you consider a good
> start because the quote "Limited dependence should be placed on operator
> precedence rules in expressions" I think MISRA costs money.

If you use MISRA in a professional context, you should of course buy a
copy, but if you're just curious or it's for your own personal use, then
it's easy to get ahold of a copy.

But I explicitely mentioned the rule number that applied here, and with
this number, you'll find the details online very easily without needing
to get the whole document.

The same kind of issue can be found here:
https://cwe.mitre.org/data/definitions/783.html , and this rule is also
part of CERT-C.

Re: operator precedence

<87mtgmp5kr.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21247&group=comp.lang.c#21247

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Fri, 15 Apr 2022 19:25:08 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <87mtgmp5kr.fsf@bsb.me.uk>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t3c9vm$d1r$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="f8b67a7155e27a25649c34539ea91f50";
logging-data="948"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GvxVP9LwTEIs1m8sHX5VwcFCKmFWTQuo="
Cancel-Lock: sha1:94ilM5E20aQNrgJaN1f+gGambXQ=
sha1:KVZe6k4bQQjhRJ4cMo19WRy6RL8=
X-BSB-Auth: 1.0bd1b8b6e4652ec4c448.20220415192508BST.87mtgmp5kr.fsf@bsb.me.uk
 by: Ben - Fri, 15 Apr 2022 18:25 UTC

Guillaume <message@bottle.org> writes:

> Le 11/04/2022 à 22:27, Ben a écrit :
>> I shall have to remain in the dark then about what you consider a good
>> start because the quote "Limited dependence should be placed on operator
>> precedence rules in expressions" I think MISRA costs money.
>
> If you use MISRA in a professional context, you should of course buy a
> copy, but if you're just curious or it's for your own personal use,
> then it's easy to get ahold of a copy.
>
> But I explicitely mentioned the rule number that applied here, and
> with this number, you'll find the details online very easily without
> needing to get the whole document.

I didn't succeed. Only spent a few minutes but all I could find is
people quoting some (or many all of) that rule in compliance statements.

One says:

"MISRA C:2012 Rule 12.1: The precedence of operators within
expressions should be made explicit"

but that can't be the whole rule and, as quoted, it sounds very odd.

> The same kind of issue can be found here:
> https://cwe.mitre.org/data/definitions/783.html , and this rule is
> also part of CERT-C.

I could not find a rule on that page, but then it has a lot of detailed
content. I found "Potential mitigations":

"Regularly wrap sub-expressions in parentheses, especially in
security-critical code."

but that hardly helps to know where anyone draws the line.

--
Ben.

Re: operator precedence

<t3jjtq$5s1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21261&group=comp.lang.c#21261

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 18 Apr 2022 14:00:57 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <t3jjtq$5s1$1@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t39149$brl$1@dont-email.me> <87ilrbu82a.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Apr 2022 12:00:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="35eb9afadf5b2d8b092ff642766740f8";
logging-data="6017"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+57JNfhMeOILMqEKYhPG67BS3aZ6SfnY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:0y1s+GDVe79BV82j8AS5f8douKc=
In-Reply-To: <87ilrbu82a.fsf@bsb.me.uk>
Content-Language: en-GB
 by: David Brown - Mon, 18 Apr 2022 12:00 UTC

On 14/04/2022 15:07, Ben wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> I have had to write code to MISRA standards a couple of times. Some
>> aspects were fine, others were annoying, but it is not the worst I
>> have dealt with. Maintaining code written with no thought or regard
>> to readability, or by smart-arse programmers, is worse IME. A coding
>> standard does not force people to write clear code, nor does a lack of
>> a standard imply code is not clear. But standards can limit some of
>> the worst aspects of code.
>
> Compared to many here, my experience is limited, but I did not get that
> impression from that limited experience. Coding standards are almost
> always about the surface syntax, and all the headaches I remember having
> with other people's code had nothing whatsoever to do with the surface
> syntax.
>

I certainly have had headaches from what you might call "surface syntax"
(noting that without trying to give a definition of that term, we might
be talking past each other), though I agree that the worst headaches
come from other aspects of the code. And on the other side, MISRA and
many other standards are not restricted solely to "surface syntax".

Coding standard rules, IMHO, can usually be grouped as obvious (such as
"don't rely on undefined behaviour"), useful, and counter-productive for
at least some times of code (such as banning compiler-specific features,
which will often make microcontroller code impossible to write). The
division lines are not constant, and there is some overlap. Coding
standards need to be used carefully and appropriately, not blindly.

Directive 1.1 of MISRA C 2012 says "Any implementation-defined behaviour
on which the output of the program depends shall be documented and
understood". That is far from "surface syntax", and a good idea (albeit
one never fully implemented in practice).

Re: operator precedence

<t3jkir$9t7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21262&group=comp.lang.c#21262

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 18 Apr 2022 14:12:11 +0200
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <t3jkir$9t7$1@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t3c9vm$d1r$1@gioia.aioe.org> <87mtgmp5kr.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 18 Apr 2022 12:12:11 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="35eb9afadf5b2d8b092ff642766740f8";
logging-data="10151"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x7BDDNMswulRHN0vA0+AYKfPqnoDZS9U="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:VXPlZsJGOU4qPh39Kk1ZsF0xGc4=
In-Reply-To: <87mtgmp5kr.fsf@bsb.me.uk>
Content-Language: en-GB
 by: David Brown - Mon, 18 Apr 2022 12:12 UTC

On 15/04/2022 20:25, Ben wrote:
> Guillaume <message@bottle.org> writes:
>
>> Le 11/04/2022 à 22:27, Ben a écrit :
>>> I shall have to remain in the dark then about what you consider a good
>>> start because the quote "Limited dependence should be placed on operator
>>> precedence rules in expressions" I think MISRA costs money.
>>
>> If you use MISRA in a professional context, you should of course buy a
>> copy, but if you're just curious or it's for your own personal use,
>> then it's easy to get ahold of a copy.
>>
>> But I explicitely mentioned the rule number that applied here, and
>> with this number, you'll find the details online very easily without
>> needing to get the whole document.
>
> I didn't succeed. Only spent a few minutes but all I could find is
> people quoting some (or many all of) that rule in compliance statements.
>
> One says:
>
> "MISRA C:2012 Rule 12.1: The precedence of operators within
> expressions should be made explicit"
>
> but that can't be the whole rule and, as quoted, it sounds very odd.
>

It is not the whole rule, which is fleshed out more and has a number of
examples. It is also an "advisory" rule, rather than a "required" rule,
and it contains the rationale note:

"""
It is recognized that overuse of parentheses can clutter the code and
reduce its readability. This rule aims to achieve a compromise between
code that is hard to understand because it contains either too many or
too few parentheses.
"""

Whether or not you think it succeeds in this aim is, clearly, a matter
of opinion!

An example of a non-compliant expression is :

x = a == b ? a : a - b;

with the compliant version being :

x = ( a == b ) ? a : ( a - b );

Personally, I'd write the second form, but with different spacing:

x = (a == b) ? a : (a - b);

To my eyes, that is the version that is quickest to parse correctly, and
least likely for anyone to parse incorrectly no matter how much or how
little time they spent looking at it, or how familiar they are with the
precedence rules of the language.

Re: operator precedence

<20220418091807.644@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21263&group=comp.lang.c#21263

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 18 Apr 2022 16:38:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <20220418091807.644@kylheku.com>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t3c9vm$d1r$1@gioia.aioe.org> <87mtgmp5kr.fsf@bsb.me.uk>
<t3jkir$9t7$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 18 Apr 2022 16:38:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="6aab72b3d451db54ac71f617edd25812";
logging-data="32452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9aQIo+RbDUS1baCjI5QM1W03k0kexYng="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:JA/m2Cx0EHGf/6gilhX1J6ZjVhI=
 by: Kaz Kylheku - Mon, 18 Apr 2022 16:38 UTC

On 2022-04-18, David Brown <david.brown@hesbynett.no> wrote:
> On 15/04/2022 20:25, Ben wrote:
>> Guillaume <message@bottle.org> writes:
>>
>>> Le 11/04/2022 à 22:27, Ben a écrit :
>>>> I shall have to remain in the dark then about what you consider a good
>>>> start because the quote "Limited dependence should be placed on operator
>>>> precedence rules in expressions" I think MISRA costs money.
>>>
>>> If you use MISRA in a professional context, you should of course buy a
>>> copy, but if you're just curious or it's for your own personal use,
>>> then it's easy to get ahold of a copy.
>>>
>>> But I explicitely mentioned the rule number that applied here, and
>>> with this number, you'll find the details online very easily without
>>> needing to get the whole document.
>>
>> I didn't succeed. Only spent a few minutes but all I could find is
>> people quoting some (or many all of) that rule in compliance statements.
>>
>> One says:
>>
>> "MISRA C:2012 Rule 12.1: The precedence of operators within
>> expressions should be made explicit"
>>
>> but that can't be the whole rule and, as quoted, it sounds very odd.
>>
>
> It is not the whole rule, which is fleshed out more and has a number of
> examples. It is also an "advisory" rule, rather than a "required" rule,
> and it contains the rationale note:
>
> """
> It is recognized that overuse of parentheses can clutter the code and
> reduce its readability. This rule aims to achieve a compromise between
> code that is hard to understand because it contains either too many or
> too few parentheses.
> """
>
> Whether or not you think it succeeds in this aim is, clearly, a matter
> of opinion!
>
> An example of a non-compliant expression is :
>
> x = a == b ? a : a - b;
>
> with the compliant version being :
>
> x = ( a == b ) ? a : ( a - b );

This is actually a really poor example.

What if I don't remember whether = has a lower precedence than ?:

If your answer is that it obviously does, then we can easily
argue that, likewise, == and - "obviously" have a higher precedence, and
so nothing needs parenthesizing.

Rather, if I were only allowed to insert one set of parentheses, I would
prioritize the insertion of this pair:

x = (a == b ? a : a - b)

Then if additional parens were still needed:

x = ((a == b) ? (a) : (a - b))

The inner one is for consistency: a is parallel with a - b.
This is analogous to bracing both branches of if/else if one
branch is braced.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: operator precedence

<t3k6l3$j4d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21267&group=comp.lang.c#21267

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 18 Apr 2022 19:20:34 +0200
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <t3k6l3$j4d$1@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t3c9vm$d1r$1@gioia.aioe.org> <87mtgmp5kr.fsf@bsb.me.uk>
<t3jkir$9t7$1@dont-email.me> <20220418091807.644@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 18 Apr 2022 17:20:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="35eb9afadf5b2d8b092ff642766740f8";
logging-data="19597"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+itmj0zYSZ+hLX3qf89z1PPrNPg9sgZMg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:qFGnlY8ArcDfvYCRVuMd2x50vrk=
In-Reply-To: <20220418091807.644@kylheku.com>
Content-Language: en-GB
 by: David Brown - Mon, 18 Apr 2022 17:20 UTC

On 18/04/2022 18:38, Kaz Kylheku wrote:
> On 2022-04-18, David Brown <david.brown@hesbynett.no> wrote:
>> On 15/04/2022 20:25, Ben wrote:
>>> Guillaume <message@bottle.org> writes:
>>>
>>>> Le 11/04/2022 à 22:27, Ben a écrit :
>>>>> I shall have to remain in the dark then about what you consider a good
>>>>> start because the quote "Limited dependence should be placed on operator
>>>>> precedence rules in expressions" I think MISRA costs money.
>>>>
>>>> If you use MISRA in a professional context, you should of course buy a
>>>> copy, but if you're just curious or it's for your own personal use,
>>>> then it's easy to get ahold of a copy.
>>>>
>>>> But I explicitely mentioned the rule number that applied here, and
>>>> with this number, you'll find the details online very easily without
>>>> needing to get the whole document.
>>>
>>> I didn't succeed. Only spent a few minutes but all I could find is
>>> people quoting some (or many all of) that rule in compliance statements.
>>>
>>> One says:
>>>
>>> "MISRA C:2012 Rule 12.1: The precedence of operators within
>>> expressions should be made explicit"
>>>
>>> but that can't be the whole rule and, as quoted, it sounds very odd.
>>>
>>
>> It is not the whole rule, which is fleshed out more and has a number of
>> examples. It is also an "advisory" rule, rather than a "required" rule,
>> and it contains the rationale note:
>>
>> """
>> It is recognized that overuse of parentheses can clutter the code and
>> reduce its readability. This rule aims to achieve a compromise between
>> code that is hard to understand because it contains either too many or
>> too few parentheses.
>> """
>>
>> Whether or not you think it succeeds in this aim is, clearly, a matter
>> of opinion!
>>
>> An example of a non-compliant expression is :
>>
>> x = a == b ? a : a - b;
>>
>> with the compliant version being :
>>
>> x = ( a == b ) ? a : ( a - b );
>
> This is actually a really poor example.
>
> What if I don't remember whether = has a lower precedence than ?:

You have to require /some/ knowledge of C. Assignments are the lowest
precedence (other than the comma operator, which MISRA bans or at least
strongly discourages anyway). Similarly, MISRA expects you to
understand that the unary operators have higher precedence.

>
> If your answer is that it obviously does, then we can easily
> argue that, likewise, == and - "obviously" have a higher precedence, and
> so nothing needs parenthesizing.
>
> Rather, if I were only allowed to insert one set of parentheses, I would
> prioritize the insertion of this pair:
>
> x = (a == b ? a : a - b)
>
> Then if additional parens were still needed:
>
> x = ((a == b) ? (a) : (a - b))
>
> The inner one is for consistency: a is parallel with a - b.
> This is analogous to bracing both branches of if/else if one
> branch is braced.
>

To me, this is not so much a matter of remembering the precedence rules
as being able to tell at a glance what the expression means - and making
it as difficult as possible for (almost) anyone to misinterpret it when
reading it, even if they have different habits for spacing or
parenthesising.

I believe it is highly unlikely for "x=a + b;" to be misinterpreted,
thus adding parenthesis is unhelpful. But "x=a == b?a:a-b;" could
certainly lead to confusion, or at least longer parse times - putting
parenthesis as suggested by MISRA would help, putting them where you
suggested would not.

(There are no absolute facts here - only opinions, preferences, and
experiences. Maybe there are also studies and statistics - MISRA is a
large industry body that does that kind of thing, unlike this newsgroup!)

Re: operator precedence

<t3l92o$pvr$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21274&group=comp.lang.c#21274

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Mon, 18 Apr 2022 23:08:08 -0400
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <t3l92o$pvr$2@dont-email.me>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t3c9vm$d1r$1@gioia.aioe.org> <87mtgmp5kr.fsf@bsb.me.uk>
<t3jkir$9t7$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Apr 2022 03:08:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1431d2ee6fc5d1babb09c90df67e12a2";
logging-data="26619"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bry7ELbQ+S92Yo2bt5lR5gEDVMI/SMXg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Cancel-Lock: sha1:S+/JVEuNdF7OBGggAU5iPv6pgMg=
In-Reply-To: <t3jkir$9t7$1@dont-email.me>
Content-Language: en-US
 by: James Kuyper - Tue, 19 Apr 2022 03:08 UTC

On 4/18/22 08:12, David Brown wrote:
> On 15/04/2022 20:25, Ben wrote:
....
>> One says:
>>
>> "MISRA C:2012 Rule 12.1: The precedence of operators within
>> expressions should be made explicit"
>>
>> but that can't be the whole rule and, as quoted, it sounds very odd.
>>
>
> It is not the whole rule, which is fleshed out more and has a number of
> examples. It is also an "advisory" rule, rather than a "required" rule,
> and it contains the rationale note:
>
> """
> It is recognized that overuse of parentheses can clutter the code and
> reduce its readability. This rule aims to achieve a compromise between
> code that is hard to understand because it contains either too many or
> too few parentheses.
> """
>
> Whether or not you think it succeeds in this aim is, clearly, a matter
> of opinion!
>
> An example of a non-compliant expression is :
>
> x = a == b ? a : a - b;
>
> with the compliant version being :
>
> x = ( a == b ) ? a : ( a - b );
>
>
> Personally, I'd write the second form, but with different spacing:
>
> x = (a == b) ? a : (a - b);
>
> To my eyes, that is the version that is quickest to parse correctly, and
> least likely for anyone to parse incorrectly no matter how much or how
> little time they spent looking at it, or how familiar they are with the
> precedence rules of the language.
>

This reminds be a discussion I had in 2014 (with you, in fact) about
MISRA Rule 34 (required):
"The operands of a logical && or || shall be primary expressions if the
operands contain binary operators."

I pointed out that this rule mandates that at least one pair of
parentheses be inserted in the following expression:

(a && b) && c

because '&&' is a binary operator, and a && b is the left operand of the
second && operator.

I also pointed out that, "the operands contain" could either be
interpreted as meaning "both operands contain", which would allow a + b
&& c, or "either operand contains", which would require (a+b) && (c).

As far as I can tell from the MISRA rules I've been told about so far,
they are often poorly thought out, poorly written, or overly restrictive.

Re: operator precedence

<20220419102826.181@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21293&group=comp.lang.c#21293

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: operator precedence
Date: Tue, 19 Apr 2022 17:40:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 153
Message-ID: <20220419102826.181@kylheku.com>
References: <thought-20220408125437@ram.dialup.fu-berlin.de>
<t2v61c$ej9$1@gioia.aioe.org> <87bkx868cm.fsf@bsb.me.uk>
<t31tda$1ohm$1@gioia.aioe.org> <878rsb4b8g.fsf@bsb.me.uk>
<t3c9vm$d1r$1@gioia.aioe.org> <87mtgmp5kr.fsf@bsb.me.uk>
<t3jkir$9t7$1@dont-email.me> <20220418091807.644@kylheku.com>
<t3k6l3$j4d$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Apr 2022 17:40:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f2d5401f7cf466380e1b071302da3061";
logging-data="21952"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0JY3KHzVUxd7/WwK+rJ7U01CD0ONxDyc="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:HAGgC5F4PmhHY4pFoaHyPthPsRw=
 by: Kaz Kylheku - Tue, 19 Apr 2022 17:40 UTC

On 2022-04-18, David Brown <david.brown@hesbynett.no> wrote:
> On 18/04/2022 18:38, Kaz Kylheku wrote:
>> On 2022-04-18, David Brown <david.brown@hesbynett.no> wrote:
>>> On 15/04/2022 20:25, Ben wrote:
>>>> Guillaume <message@bottle.org> writes:
>>>>
>>>>> Le 11/04/2022 à 22:27, Ben a écrit :
>>>>>> I shall have to remain in the dark then about what you consider a good
>>>>>> start because the quote "Limited dependence should be placed on operator
>>>>>> precedence rules in expressions" I think MISRA costs money.
>>>>>
>>>>> If you use MISRA in a professional context, you should of course buy a
>>>>> copy, but if you're just curious or it's for your own personal use,
>>>>> then it's easy to get ahold of a copy.
>>>>>
>>>>> But I explicitely mentioned the rule number that applied here, and
>>>>> with this number, you'll find the details online very easily without
>>>>> needing to get the whole document.
>>>>
>>>> I didn't succeed. Only spent a few minutes but all I could find is
>>>> people quoting some (or many all of) that rule in compliance statements.
>>>>
>>>> One says:
>>>>
>>>> "MISRA C:2012 Rule 12.1: The precedence of operators within
>>>> expressions should be made explicit"
>>>>
>>>> but that can't be the whole rule and, as quoted, it sounds very odd.
>>>>
>>>
>>> It is not the whole rule, which is fleshed out more and has a number of
>>> examples. It is also an "advisory" rule, rather than a "required" rule,
>>> and it contains the rationale note:
>>>
>>> """
>>> It is recognized that overuse of parentheses can clutter the code and
>>> reduce its readability. This rule aims to achieve a compromise between
>>> code that is hard to understand because it contains either too many or
>>> too few parentheses.
>>> """
>>>
>>> Whether or not you think it succeeds in this aim is, clearly, a matter
>>> of opinion!
>>>
>>> An example of a non-compliant expression is :
>>>
>>> x = a == b ? a : a - b;
>>>
>>> with the compliant version being :
>>>
>>> x = ( a == b ) ? a : ( a - b );
>>
>> This is actually a really poor example.
>>
>> What if I don't remember whether = has a lower precedence than ?:
>
> You have to require /some/ knowledge of C. Assignments are the lowest
> precedence (other than the comma operator, which MISRA bans or at least
> strongly discourages anyway). Similarly, MISRA expects you to
> understand that the unary operators have higher precedence.
>
>>
>> If your answer is that it obviously does, then we can easily
>> argue that, likewise, == and - "obviously" have a higher precedence, and
>> so nothing needs parenthesizing.
>>
>> Rather, if I were only allowed to insert one set of parentheses, I would
>> prioritize the insertion of this pair:
>>
>> x = (a == b ? a : a - b)
>>
>> Then if additional parens were still needed:
>>
>> x = ((a == b) ? (a) : (a - b))
>>
>> The inner one is for consistency: a is parallel with a - b.
>> This is analogous to bracing both branches of if/else if one
>> branch is braced.
>>
>
> To me, this is not so much a matter of remembering the precedence rules
> as being able to tell at a glance what the expression means - and making
> it as difficult as possible for (almost) anyone to misinterpret it when
> reading it, even if they have different habits for spacing or
> parenthesising.
>
> I believe it is highly unlikely for "x=a + b;" to be misinterpreted,
> thus adding parenthesis is unhelpful. But "x=a == b?a:a-b;" could
> certainly lead to confusion, or at least longer parse times - putting
> parenthesis as suggested by MISRA would help, putting them where you
> suggested would not.

Sure, OK. But then, what is the point of the "x = " in the MISRA
example?

x = ( a == b ) ? a : ( a - b );

The possibility remains that this be misread as:

(x = ( a == b )) ? a : ( a - b );

Why is the assignment included in this example; if its apparent
ambiguity isn't being taken care of?

What it is that the reader is supposed to be confused by if we remove
the left pair of parentheses.

x = a == b ? a : ( a - b );

Are the parentheses supposed to rule out this misparse?

x = a == (b ? a : ( a - b )).

If so, that can be demonstrated without the x = because it's
an internal matter within just ternary expression.

Or is it this misparse:

(x = a) == b ? a : ( a - b ).

But that is an issue between just the = and == operator that
can be put into a simpler recommendation, like

"parenthesize equality/inequality expressions that are next to
assignment operators. Don't write:

flag = foo == bar

but

flag = (foo == bar)

or

row += i % 10 == 0

but rather

row += (i % 10 == 0)"

The thing is that x = y ? z : w is actually a famous ambiguity,
which revolves around the precedence of = versus ?:.
Someone who thinks = is higher misreads it as (x = y) ? z : w.
This can be a valid interpretation of z and w have side effects.

Parenthesizing y does nothing: x = (y) ? z : w.

You need: x = (y ? z : w). Aha, only y is tested, and then
x receives either z or w.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Pages:1234
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor