Deutsch   English   Français   Italiano  
<86plqe9igg.fsf@linuxsc.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!3.eu.feeder.erje.net!feeder.erje.net!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: relearning C: why does an in-place change to a char* segfault?
Date: Mon, 12 Aug 2024 02:52:15 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86plqe9igg.fsf@linuxsc.com>
References: <IoGcndcJ1Zm83zb7nZ2dnZfqnPWdnZ2d@brightview.co.uk> <v8fhhl$232oi$1@dont-email.me> <v8fn2u$243nb$1@dont-email.me> <87jzh0gdru.fsf@nosuchdomain.example.com> <v8gte2$2ceis$2@dont-email.me> <20240801174256.890@kylheku.com> <v8i9o8$2oof8$1@dont-email.me> <v8j808$2us0r$1@dont-email.me> <v8k194$33ib3$3@dont-email.me> <7b14896deb848aa407618505d06bfe4658197918@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Mon, 12 Aug 2024 11:52:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f42e4005105099d89c60a754521770ce";
	logging-data="3404816"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+7ZKTSWUZkke80Boft00irsyWnoktvBgU="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:LkUveeXM8UXdtWMev9GB/uoRn0Y=
	sha1:K5fA2o/H8Q4m4RerXIWhsbNsaXI=
Bytes: 2776

Richard Damon <richard@damon-family.org> writes:

> On 8/2/24 9:31 PM, Lawrence D'Oliveiro wrote:
>
>> On Fri, 2 Aug 2024 14:19:49 -0400, James Kuyper wrote:
>>
>>> I've heard that in some other
>>> languages, if you call foo(3), and foo() changes the value of it's
>>> argument to 2, then subsequent calls to bar(3) will pass a value of 2 to
>>> bar().  That sounds like such a ridiculous mis-feature that I hesitate to
>>> identify which languages I had heard accused of having that feature ...
>>
>> I heard that, too.  I think it was on some early FORTRAN compilers, on
>> early machine architectures, without stacks or reentrancy.  And with the
>> weird FORTRAN argument-passing conventions.
>
> I remember it too, and was based on the fact that all arguments were
> pass by reference (so they could be either in or out parameters), and
> constants were passed as pointers to the location of memory where that
> constant was stored, and perhaps used elsewhere too.  Why waste
> precious memory to setup a temporary to hold be initialized and hold
> the value, when you could just pass the address of a location that you
> knew had the right value.

I think the original FORTRAN, and FORTRAN II, used call by reference.
In the early 1960s FORTRAN changed to using call by value-result
(which is similar to call by reference but slightly different).