Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #2826
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end |
|---|---|
| From | David Brown <david.brown@hesbynett.no> |
| Newsgroups | comp.compilers |
| Subject | Re: what is defined, was for or against equality |
| Date | Thu, 13 Jan 2022 08:24:32 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 59 |
| Sender | news@iecc.com |
| Approved | comp.compilers@iecc.com |
| Message-ID | <22-01-050@comp.compilers> (permalink) |
| References | <17d70d74-1cf1-cc41-6b38-c0b307aeb35a@gkc.org.uk> <22-01-016@comp.compilers> <22-01-018@comp.compilers> <22-01-020@comp.compilers> <22-01-027@comp.compilers> <22-01-032@comp.compilers> <22-01-038@comp.compilers> <22-01-041@comp.compilers> <22-01-044@comp.compilers> <22-01-045@comp.compilers> <22-01-046@comp.compilers> <22-01-048@comp.compilers> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="8334"; mail-complaints-to="abuse@iecc.com" |
| Keywords | standards |
| Posted-Date | 14 Jan 2022 12:39:06 EST |
| X-submission-address | compilers@iecc.com |
| X-moderator-address | compilers-request@iecc.com |
| X-FAQ-and-archives | http://compilers.iecc.com |
| In-Reply-To | <22-01-048@comp.compilers> |
| Content-Language | en-GB |
| Xref | csiph.com comp.compilers:2826 |
Show key headers only | View raw
On 12/01/2022 20:02, Thomas Koenig wrote: > gah4 <gah4@u.washington.edu> schrieb: >> On Tuesday, January 11, 2022 at 11:47:26 AM UTC-8, Kaz Kylheku wrote: >> 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 was under the impression that FORTRAN compilers typically put data in the ".common" section of object files. A key difference between .common and .bss is that (with standard linker setup) duplicate symbols in .bss are an error, while duplicate symbols in .common are merged. But in C startup code, .common is also zeroed (FORTRAN may have different startup code here - with no experience of the language, I don't know such details). The use of ".common" by C compilers such as gcc was common practice precisely to improve compatibility with FORTRAN in the early days, and it let people write "int global_x;" in headers and have everything work, rather than the correct practice of "extern int global_x;" in headers and a single "int global_x;" in one object file. The big disadvantages are that if you have "int local_x;" in two files, and don't use static, they'll be merged with no error, and if you have "int global_x;" in one file and "double global_x;" in another, it's a mess. Modern gcc now uses "-fno-common" to avoid this. > >> 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. AFAIUI the difference in aliasing rules is that in FORTRAN, pointer or array parameters are assumed not to alias, while in C the compiler must assume that they might alias, unless you use "restrict". Are there other differences?
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Re: for or against equality, was Why are ambiguous grammars usually a bad idea? Martin Ward <martin@gkc.org.uk> - 2022-01-05 10:25 +0000
Re: for or against equality, was Why are ambiguous grammars usually a bad idea? David Brown <david.brown@hesbynett.no> - 2022-01-06 09:11 +0100
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-06 16:43 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-07 12:06 +0100
Re: what is defined, was for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-07 13:21 +0000
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-08 09:31 +0000
Re: what is defined, was for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-08 22:28 +0000
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-09 00:09 +0000
Re: what is defined, was for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-09 21:30 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-09 23:00 +0100
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-10 12:04 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-11 18:16 +0100
Re: what is defined, was for or against equality Kaz Kylheku <480-992-1380@kylheku.com> - 2022-01-11 19:19 +0000
Re: what is defined, was for or against equality gah4 <gah4@u.washington.edu> - 2022-01-11 14:18 -0800
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-12 19:02 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-13 08:24 +0100
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-13 11:17 +0000
Re: what is defined, was for or against equality gah4 <gah4@u.washington.edu> - 2022-01-10 16:58 -0800
Re: for or against equality, was Why are ambiguous grammars usually a bad idea? Robert Prins <robert@prino.org> - 2022-01-06 19:07 +0000
Undefined behaviour, was: for or against equality Martin Ward <martin@gkc.org.uk> - 2022-01-07 14:02 +0000
Re: Undefined behaviour, was: for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-08 03:41 +0000
Re: Undefined behaviour, was: for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-07 15:56 +0100
Re: Undefined behaviour, was: for or against equality anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2022-01-08 17:52 +0000
Re: Undefined behaviour, was: for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-09 23:53 +0100
Re: Undefined behaviour, was: for or against equality Kaz Kylheku <480-992-1380@kylheku.com> - 2022-01-11 16:55 +0000
Re: Undefined behaviour, was: for or against equality George Neuner <gneuner2@comcast.net> - 2022-01-11 22:01 -0500
csiph-web