Re: [hackers-il] change the value of 4
- "Nadav Har'El" <nyh@...> writes:
> Now, here comes the problem: What does fortran do when you call F(4)? ItI can easily believe that there were implementations that did just that.
> cannot pass the literal "4", and must instead set up a memory space, put
> a 4 in it, and give F the pointer to that memory space. One implementation
> I checked (and it will be interesting to check if g77 also does this) chooses
> not to reset that memory position to 4 on every call to F(4). So if F changes
> its parameter to 5 (remember, it is allowed to do that), the next calls to
> F(4) might actually give F a parameter 5! The compiler might (and I don't
> remember checking that) even use the same memory location for several "4"s
> mentioned in the program, so all 4s are changed into 5s :)
However, normally you'll segfault in any sane compiler, I believe.
G77 is not smart enough to warn you at compile time that you are
trying to do something illegal. The following code
x = 5
compiles cleanly with g77 and segfaults at "x = 5" at run time. This
is, of course, the same behaviour as in your "ruin" C example.
Oleg Goldshmidt | ogoldshmidt@...
If it aint't broken it hasn't got enough features yet.