Article View: comp.lang.c
Article #684Re: why &| dont work and its possible to make it work
From: Kaz Kylheku
Date: Thu, 22 Oct 2026 20:13
Date: Thu, 22 Oct 2026 20:13
33 lines
2421 bytes
2421 bytes
On 2026-10-22, Scott Lurndal <scott@slp53.sl.home> wrote:
> fir <profesor.fir@gmail.com> writes:
>>sady this plan of using | & failed becouse its said that here for example
>>
>> if(target<0 ||target>=bag_max ||!bag[target].enabled) {}
>>
>>if target is -1 in case of | the last one will be evalueated too
>>and it may be segfault
>
> If the first test is true, the remaining tests will not be
> executed.
>
> If you knew C, you'd have known that.
Problem is fir said "in case of |"; i.e. "if the operator | is
substituted for || in the above expression".
It's hard to spot things like this in the broken/loose english with low
punctuation and capitalization.
A token substitution in the syntax requiring us to edit, recompile and
redeploy the program image is not exactly a "case"; we normally
don't talk about it that way, let alone as an apparently subordinate
condition to a run time value like target == -1.
"If we change || to | in the above, and then hit the value target == -1
at run-time, then bag[target] is still evaluated, with the out-of-bounds
target index."
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Technical Details
Message-ID:
<20261022130030.580@kylheku.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<117mere$3a14a$1@dont-email.me> <11bda5e$vdh3$1@dont-email.me> <%EtCS.3$dnHe.0@fx46.iad>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <046-301-5902@kylheku.com> Newsgroups: comp.lang.c Subject: Re: why &| dont work and its possible to make it work Date: Thu, 22 Oct 2026 20:13:13 -0000 (UTC) Organization: A noiseless patient Spider Lines: 33 Message-ID: <20261022130030.580@kylheku.com> References: <117mere$3a14a$1@dont-email.me> <11bda5e$vdh3$1@dont-email.me> <%EtCS.3$dnHe.0@fx46.iad> Injection-Date: Thu, 22 Oct 2026 20:13:14 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1247632"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+h8rBCq9/prk2PXpQ7oTJdQE2+tSmZ1kw="; posting-host="1cad69a6b5b45f8923c6c28fc75c62ba" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:t7bZxb1wRSBDlFeyofK9jr8gD+k= sha256:hppv92jPO6SRuXnFnCzmuNEjolaFltesk7LIeUYLMo0= sha1:Fr74wEf18ZJzHzUYKwepaD/7sdQ= sha256:8AoJ5ahVhUyGFfqsKAWcqY5wdneXQGNyXiZU1vKK96g=