Deutsch   English   Français   Italiano  
<v594h7$ban8$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: Can you please verify that the analysis of these C functions is
 correct?
Date: Sun, 23 Jun 2024 14:30:31 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <v594h7$ban8$1@dont-email.me>
References: <v4obkj$f9p5$2@dont-email.me>
 <v4pg5p$morv$1@raubtier-asyl.eternal-september.org>
 <v54s1p$3boc5$1@dont-email.me> <v5684p$3n50u$1@dont-email.me>
 <v56gs1$3olbi$3@dont-email.me> <v56lar$onl4$7@i2pn2.org>
 <v56uij$3rako$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 23 Jun 2024 14:30:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5355e1e2ebba64f698c289003534b1d6";
	logging-data="371432"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+dX8TczetggzdYD56Cn86aCaPMfkm3nyY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:fyJYtxxz9RSevccUS3vmYGyFKgU=
In-Reply-To: <v56uij$3rako$1@dont-email.me>
Content-Language: en-GB
Bytes: 2664

On 22/06/2024 18:36, olcott wrote:
> On 6/22/2024 8:58 AM, Richard Damon wrote:
>> On 6/22/24 8:42 AM, olcott wrote:
>>> On 6/22/2024 5:13 AM, Richard Harnden wrote:

>>>>
>>> I would say that this would indicate that you are insufficiently
>>> competent with the C programming language.
>>>
>>
>> It seems you are the one that doesn't know the C programing language. 
>> After all, you didn't know about the unordering of sub-expressions, or 
>> that this can lead to undefined behavior.
> 
> It seems pretty stupid to allow gaps in the semantics of C++ programs. 
> Simply specify that the order of evaluation is left to right unless:
> (a) Otherwise specified such as operator precedence rules.
> (b) Derives the same result as left to right ordering.
> 

The tighter you specify something, the less scope there is for 
optimisations and generating more efficient code.  It's a tradeoff.  C 
and C++, as languages aimed at (amongst other uses) generating efficient 
code, have design decisions that give more flexibility to the compilers 
rather than specifying the details of how implementations must work.

It is very simple to enforce the logical order of calculation of 
subexpressions - use temporary variables.  So the programmer has the 
choice you are looking for, but needs to express it in a different way 
from what you thought.