Re: what is defined, was for or against equality

Thomas Koenig <tkoenig@netcologne.de>
Wed, 12 Jan 2022 19:02:48 -0000 (UTC)

          From comp.compilers

Related articles
[7 earlier articles]
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: Thomas Koenig <tkoenig@netcologne.de>
Newsgroups: comp.compilers
Date: Wed, 12 Jan 2022 19:02:48 -0000 (UTC)
Organization: news.netcologne.de
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 22-01-044 22-01-045 22-01-046
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="47748"; mail-complaints-to="abuse@iecc.com"
Keywords: standards, comment
Posted-Date: 12 Jan 2022 17:53:19 EST

gah4 <gah4@u.washington.edu> schrieb:
> On Tuesday, January 11, 2022 at 11:47:26 AM UTC-8, Kaz Kylheku wrote:
>
> (big snip)
>
>> This leaves a lot of room for Fortran and C to have entirely different
>> defined/undefined behaviors.
>
>> Even the front end for one single language can have a lot of switches
>> affecting what is defined or not.
>
> I suppose so. But more usual, the compiler works to the least
> common denominator.
>
> For one, C requires static variables, and especially external ones, to
> initialize to zero, but Fortran doesn't. Fortran compilers that use C
> compiler middle and back ends, tend to zero such variables.


This is more a matter of operating system and linker conventions
than of compilers.


Looking at the ELF standard, one finds


.bss


This section holds uninitialized data that contribute to the program's
memory image. By definition, the system initializes the data with zeros
when the program begins to run. The section occupies no file space, as
indicated by the section type, SHT_NOBITS.


which, unsurprisingly, matches exactly what C is doing.


Anybody who writes a Fortran compiler for an ELF system will
use .bss for COMMOM blocks, because it is easiest. Initialization
with zeros then happens automatically.


> I suspect that there are many more that I don't know about.
> As long as the cost is small, and it satisfies both standards,
> not much reason not to do it.
>
> Fortran has stricter rules on aliasing than C. I don't actually know
> about any effect on C programs, though, but it might be that
> compilers do the same for C.


The rules are different, and unless C is the intermediate language,
a good compiler will hand the corresponding hints to the middle end.
[I have used Fortran systems that initialized otherwise undefined data to a value that would
trap, to help find use-before-set errors. -John]


Post a followup to this message

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