Deutsch   English   Français   Italiano  
<1bwmkxhe3j.fsf@pfeifferfamily.net>

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

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Joe Pfeiffer <pfeiffer@cs.nmsu.edu>
Newsgroups: comp.lang.c
Subject: Re: relearning C: why does an in-place change to a char* segfault?
Date: Sat, 03 Aug 2024 08:32:00 -0600
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <1bwmkxhe3j.fsf@pfeifferfamily.net>
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
Injection-Date: Sat, 03 Aug 2024 16:32:00 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7436bc8f164e74e82d089031afe12d54";
	logging-data="3672701"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+Ee4imOZmc3vijy4A9LeWvpf1sy1wzxLU="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:b7zRs4nCm/FnptZOof7isRSwfks=
	sha1:Bza6o0kqBABqykhbFacG51U2KWs=
Bytes: 2764

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 actually had a bug once in my FORTRAN code on a CDC6400 where I changed the
value of an argument in a function, and then passed in a constant.  That
"constant" had the new value for the rest of the program.  Finding that
one was a challenge, particularly since I was a very inexperienced
undergrad at the time.