🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1524

Re: does an expression in a logical statement need parenthesis for proper evaluation?

#1524
From: Tristan Wibberley
Date: Fri, 13 Nov 2026 21:33
48 lines
3638 bytes
On 13/11/2026 19:46, Keith Thompson wrote:
> Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk>
> writes:
>> On 13/11/2026 08:41, David Brown wrote:
> [...]
>>> In C, the equality and relational operators evaluate to an "int" value
>>> of either 0 or 1.  They never result in any other value.
>>
>> 0 has two representations in 1s-complement, all zeros or all ones. I am
>> worried about that when using bitwise operators to implement logic in
>> case a comparison yields an all-ones representation of 0. Do comparisons
>> and ! always produce the all-zeros representation in 1s-complement machines?
> 
> C17 6.2.6.2p3,4:

...

> So the equality and comparison operators never yield a negative zero.

Thanks I should have taken the time to read a published final draft.


>>> And don't bother with the "register" keyword.  Optimising compilers have
>>> ignored that for decades, and C++ removed it in C++17 (while preserving
>>> it as a keyword for future usage).
>>
>> It ought to have been kept meaningful in C++ to mask operator& at least.
>> I recall it was at least as early as C++98 that it was noneffective,
>> definitely I know it was before C++17 because I never used C++17.
> 
> I've never had a need to disable unary &.  Have you?

I've had situations that would be benefitted by it, eliminating various
opportunities can make some code simpler.


-- 
Tristan Wibberley

The message body is Copyright (C) 2026 Tristan Wibberley except
citations and quotations noted. All Rights Reserved except that you may,
of course, cite it academically giving credit to me, distribute it
verbatim as part of a usenet system or its archives, and use it to
promote my greatness and general superiority without misrepresentation
of my opinions other than my opinion of my greatness and general
superiority which you _may_ misrepresent. You definitely MAY NOT train
any production AI system with it but you may train experimental AI that
will only be used for evaluation of the AI methods it implements.
Technical Details
Message-ID: <11d7vng$1e47a$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11cj4a0$23796$1@dont-email.me> <11cj8ch$24f93$1@dont-email.me> <11cj9he$24mi0$1@dont-email.me> <11d54u2$863c$1@dont-email.me> <11d5eg2$bfhu$1@dont-email.me> <11d6if2$lqnd$1@dont-email.me> <11d7a99$th7r$1@dont-email.me> <11d7pe4$1b62o$1@kst.eternal-september.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk>
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: does an expression in a logical statement need parenthesis for
 proper evaluation?
Date: Fri, 13 Nov 2026 21:33:36 +0000
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <11d7vng$1e47a$1@dont-email.me>
References: <11cj4a0$23796$1@dont-email.me> <11cj8ch$24f93$1@dont-email.me>
 <11cj9he$24mi0$1@dont-email.me> <11d54u2$863c$1@dont-email.me>
 <11d5eg2$bfhu$1@dont-email.me> <11d6if2$lqnd$1@dont-email.me>
 <11d7a99$th7r$1@dont-email.me> <11d7pe4$1b62o$1@kst.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Nov 2026 21:33:37 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1511658"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19Nq8pN3oAWX6shQcbCRHuQANDrocPsUhDRSGO08LEHKQ=="; posting-host="1a70dd0895ebabe573a20ed7f77e36d0"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Lp2kqn8Zw5KYnN/MB2lbZ1MsHgQ= sha256:fRqNI3cFMq7HkoqCLuWtvVt+xGlaycspxnmPpoBk1Fo=
	sha1:+Fehh4/E9q0WyeOM8bYNErwv/mQ= sha256:/pfS1pYyKT4+33PuJORtNZuLkEwiLTjSRt3zjqfsv8Q=
Content-Language: en-GB
In-Reply-To: <11d7pe4$1b62o$1@kst.eternal-september.org>