Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: does char *str="abcd"; alloc addressable memory? Date: Sat, 11 Jul 2020 13:39:17 -0700 Organization: None to speak of Lines: 28 Message-ID: <87wo396b2i.fsf@nosuchdomain.example.com> References: <87k0zgbiwt.fsf@nosuchdomain.example.com> <6HCNG.37756$bQ4.31924@fx04.iad> <86fta0fw7j.fsf@linuxsc.com> <87o8oo8s31.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="afce2cd57a04b7ce2f64abcfcc7ff62f"; logging-data="9855"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18laniHOzy4ae74tLCS9d6r" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:7Kb0UTF/2wTM+1ukIbZIvKTvvrk= sha1:l1R1/Dv/B7bLWmNqf+PmitZopBA= Xref: csiph.com comp.lang.c:153202 James Kuyper writes: > On 7/10/20 11:09 PM, John Forkosh wrote: > ... >> I seem to recall, from long ago, that it was possible to accidentally >> (or on purpose, though I don't recall ever seeing/hearing of any good >> algorithmic reason to) change the value of numeric constants so that >> afterwards, e.g., i=1;i+=1;(not sure about i++) results in i==3. > > What you're describing was certainly true of Fortran, and possibly other > languages, but C has never worked that way. I vaguely recall that VAXC, an old compiler for VAX/VMS, allowed taking the address of a floating-point constant, so that for example &1.2 would yield a value of type double*. I have no idea what would happen if you tried to modify the object via that pointer value. It was never part of the C language, and I was surprised to see it (around 1998 or so). Fortunately we had the newer DECC compiler as well. This compiler was so out of date that if you wrote `x=-1`, it would issue a warning about "-=" being ambiguous and then interpret it as if you had written `x -= 1`. The old "-=" syntax for compound assignment operators is listed as obsolescent in K&R1, 1978. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */