Re: what is defined, was for or against equality

David Brown <david.brown@hesbynett.no>
Tue, 11 Jan 2022 18:16:28 +0100

          From comp.compilers

Related articles
[4 earlier articles]
Re: what is defined, was for or against equality spibou@gmail.com (Spiros Bousbouras) (2022-01-08)
Re: what is defined, was for or against equality tkoenig@netcologne.de (Thomas Koenig) (2022-01-09)
Re: what is defined, was for or against equality spibou@gmail.com (Spiros Bousbouras) (2022-01-09)
Re: what is defined, was for or against equality david.brown@hesbynett.no (David Brown) (2022-01-09)
Re: what is defined, was for or against equality tkoenig@netcologne.de (Thomas Koenig) (2022-01-10)
Re: what is defined, was for or against equality gah4@u.washington.edu (gah4) (2022-01-10)
Re: what is defined, was for or against equality david.brown@hesbynett.no (David Brown) (2022-01-11)
Re: what is defined, was for or against equality 480-992-1380@kylheku.com (Kaz Kylheku) (2022-01-11)
Re: what is defined, was for or against equality gah4@u.washington.edu (gah4) (2022-01-11)
Re: what is defined, was for or against equality tkoenig@netcologne.de (Thomas Koenig) (2022-01-12)
Re: what is defined, was for or against equality david.brown@hesbynett.no (David Brown) (2022-01-13)
Re: what is defined, was for or against equality tkoenig@netcologne.de (Thomas Koenig) (2022-01-13)
| List of all articles for this month |
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.compilers
Date: Tue, 11 Jan 2022 18:16:28 +0100
Organization: A noiseless patient Spider
References: <17d70d74-1cf1-cc41-6b38-c0b307aeb35a@gkc.org.uk> 22-01-016 22-01-018 22-01-020 22-01-027 22-01-032 22-01-038 22-01-041
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="10445"; mail-complaints-to="abuse@iecc.com"
Keywords: standards, theology
Posted-Date: 11 Jan 2022 13:08:30 EST
In-Reply-To: 22-01-041
Content-Language: en-GB

On 10/01/2022 13:04, Thomas Koenig wrote:
> David Brown <david.brown@hesbynett.no> schrieb:
>
>> The big question here, is why do you think Fortran is any different? In
>> theory, there isn't a difference - nothing you have said here convinces
>> me that there is any fundamental difference between Fortran and C in
>> regards to undefined behaviour.
>
> I am not sure how to better explain it. I will try a bit, but
> this will be my last reply to you in this thread. We seem to have
> a fundamental difference in our understanding, and seem to be
> unable to resolve it.
>


Fair enough. Maybe in a future discussion, one of us will have an
"Aha!" moment and understand the other's viewpoint, and progress will be
made - until then, there's no point in going around in circles. I'll
snip bits of your post here, and try to minimise new points (unless I
get that "Aha!") - but be sure I am reading and appreciating your entire
post.


>> (And there's no difference in the
>> implementations - the most commonly used Fortran compilers also handle
>> C, C++, and perhaps other languages.)
>
> Sort of.
>
> At the risk of boring most readers of this group, a very short, but
> (hopefully) pertinent introduction of how modern compilers work:
>
>
> There is no compiler (if you mean a single binary) that handles both
> C and Fortran. They are separate front ends to common middle
> and back ends.


Yes. But it is the middle end that handles most of the optimisations,
including those based on undefined behaviour. The front end determines
whether code can have undefined behaviour and in what circumstances.


>> C does not have a "write" function in the standard library. So the
>> behaviour of "write" is not defined by the C standards - but that does
>> not mean the behaviour is undefined.
>
> When interpreting at a language standard, you _must_ follow the
> definitions in the standards if they exist, you cannot use everyday
> interpretations.
>
> Subclause 3.4.3 (N2596) defines
>
> # undefined behavior
>
> # behavior, upon use of a nonportable or erroneous program
> # construct or of erroneous data, for which this document imposes
> # no requirements
>
> write() is nonportable and the C standard imposes no requirements
> on it. Therefore, the program above invokes undefined behavior.


No. (As always, this is based on my interpretation of the standards -
consider everything to have "IMHO" attached.) The implementation of
"write" is outside the scope of the standards, and is therefore
undefined as far as the standards are concerned. That does not make it
undefined behaviour in the program - it just means the standards don't
say what "write" should do.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.