modifying constants in Fortran and elsewhere

gah4 <gah4@u.washington.edu>
Mon, 10 Jul 2023 19:42:01 -0700

          From comp.compilers

Related articles
modifying constants in Fortran and elsewhere gah4@u.washington.edu (gah4) (2023-07-10)
Re: modifying constants in Fortran and elsewhere tkoenig@netcologne.de (Thomas Koenig) (2023-07-15)
Re: modifying constants in Fortran and elsewhere DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2023-07-16)
Re: modifying constants in Fortran and elsewhere tkoenig@netcologne.de (Thomas Koenig) (2023-07-16)
Re: modifying constants in Fortran and elsewhere gah4@u.washington.edu (gah4) (2023-07-16)
Re: modifying constants in Fortran and elsewhere gah4@u.washington.edu (gah4) (2023-07-16)
Re: modifying constants in Fortran and elsewhere david.brown@hesbynett.no (David Brown) (2023-07-17)
[1 later articles]
| List of all articles for this month |

From: gah4 <gah4@u.washington.edu>
Newsgroups: comp.compilers
Date: Mon, 10 Jul 2023 19:42:01 -0700
Organization: Compilers Central
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="66936"; mail-complaints-to="abuse@iecc.com"
Keywords: errors, history, Fortran
Posted-Date: 11 Jul 2023 20:38:33 EDT

A potential bug since the earliest days of Fortran is passing a
constant to a subroutine, and then changing the value of the dummy
argument.


In at least some Fortran system, this modifies the value of a constant
used other places in a program.


As this was known when PL/I was designed, it is defined such that
modifiable constants are passed to called procedures. C avoids it by
not allowing the & operator on constants. (Though K&R allows
modification of string constants.)


Somehow, in all the years, that feature was never added to Fortran.


It is easy to write programs and test for it, but I wonder if there
are any stories for real program that had this bug, and even better,
stories about the difficulty of finding it, or problems caused by it.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.