🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #84

Re: Optimization by programmers

#84
From: Thomas Koenig
Date: Tue, 13 Oct 2026 18:40
46 lines
3213 bytes
John Savard <quadibloc@invalid.com> schrieb:
> 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.

First, those semantics have to be defined... but I thought you were
a great fan of all things /360, so I assumed you would like this :-)

> 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.

That would penalize correct code, which is a no-no.

-- 
This USENET posting was made without artificial intelligence,
artificial impertinence, artificial arrogance, artificial stupidity,
artificial flavorings or artificial colorants.
Technical Details
Message-ID: <11altui$q4p6$1@dont-email.me>
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
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> <6acd0635.21804140@news.eternal-september.org>

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: Thomas Koenig <tkoenig@netcologne.de>
Newsgroups: comp.arch
Subject: Re: Optimization by programmers
Date: Tue, 13 Oct 2026 18:40:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <11altui$q4p6$1@dont-email.me>
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>
 <6acd0635.21804140@news.eternal-september.org>
Injection-Date: Tue, 13 Oct 2026 18:40:18 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="856870"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/0O89/Pnfx3muJ47MGBOENr2M8DysJg6o="; posting-host="45f67e85606e40618880919fc1ea7708"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:4cJTLmwea1s3rrQL90A8UEptjH4= sha256:MmOhsQT52Mhw/IFquazJmBUWcqGgy1PBJdB+lV23iQ8=
	sha1:p6RkxT1tWyoWxm0kk6ao2kePTeQ= sha256:iYP04HHvKsou8JcknuS/XMzichX9pnYNEyi/D6l60Ho=