Article View: comp.arch
Article #57Re: Optimization by programmers
From: John Savard
Date: Mon, 12 Oct 2026 16:12
Date: Mon, 12 Oct 2026 16:12
37 lines
2716 bytes
2716 bytes
On Mon, 12 Oct 2026 11:25:32 -0000 (UTC), Thomas Koenig <tkoenig@netcologne.de> wrote: >David Brown <david.brown@hesbynett.no> schrieb: > >> But if you receive a "pointer to const" parameter to a function, you can >> still write via a cast version of the pointer if the original object was >> not defined as "const". (So objects defined as "const" may be placed in >> read-only memory of some kind, and trying to change them might cause a >> crash, signal, bus-error, etc.) > >In FORTRAN, it used to be possible on systems such as /360 to write > > CALL FOO(21) > WRITE (*,*) 21 > END > > SUBROUTINE FOO(N) > N = 42 > END > >and get a printout of 42 (21 is only half the truth, >remember!) because the compiler put the constants in read/write >storage and arguments were passed via address. And the proper way to correct this error is obvious. Not by putting constants in a segment marked read-only. But in properly implementing language semantics. So the values of constants are stored in memory. However, when a constant is passed to a function as an argument, clearly that constant should be treated as an *expression*, not as a variable. So you copy it to a temporary, and pass the address of the temporary to the function. Not doing that was the bug. John Savard
Technical Details
Message-ID:
<6acd0635.21804140@news.eternal-september.org>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:
<1177fdi$26ea4$1@dont-email.me> <11a3ofn$2ak3s$1@dont-email.me> <11a5hd5$4qb$1@reader2.panix.com> <11a5lqo$2v5bq$1@dont-email.me> <11a6870$41j$1@reader2.panix.com> <11a6a6h$37i1n$1@dont-email.me> <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me> <11aig3c$3hdcn$1@dont-email.me>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: quadibloc@invalid.com (John Savard) Newsgroups: comp.arch Subject: Re: Optimization by programmers Date: Mon, 12 Oct 2026 16:12:03 GMT Organization: A noiseless patient Spider Lines: 37 Message-ID: <6acd0635.21804140@news.eternal-september.org> References: <1177fdi$26ea4$1@dont-email.me> <11a3ofn$2ak3s$1@dont-email.me> <11a5hd5$4qb$1@reader2.panix.com> <11a5lqo$2v5bq$1@dont-email.me> <11a6870$41j$1@reader2.panix.com> <11a6a6h$37i1n$1@dont-email.me> <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> Injection-Date: Mon, 12 Oct 2026 16:12:03 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3950049"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ojxfvcts/Ue3krT9OQOaSuiP78HNSaS4="; posting-host="0a8f73f571c1a9912da9a0e303bd3d3c" Cancel-Lock: sha1:PbjmAOfCxmq/X+WpIL+g5gK47hA= sha256:ZeHzN4OMd/IbcBD6CkfbHsG+IsVkiLd+stOORVk3MSE= sha1:iZmQfopsdnPs5GqZre9j5+gORxc= sha256:HpIC3dUl0Zfdf6tLwM9xrvrkieBPVG5/Vqt+zrf4QiQ= X-Newsreader: Forte Free Agent 1.1/32.230