To confirm Martin's comment: This is indeed invalid. In Fortran, when a local variable in a function is initialized in its declaration, that means that it is initialized only once when the program starts (or effectively so), and its value is then SAVE'd to subsequent calls of that function. Thus, the initialization must be a constant value that does not depend on the arguments of the function, because there are no arguments when the initial value is computed.

This is quite unlike C, where "int i = 1" just shorthand for "int i; i = 1".

My guess is the original code this was reduced from wouldn't do what you want even if it did compile, because of the fact that the initialization is only run once and then the final value SAVE'd until the next iteration. This seems to be a fairly common bug.

Regardless, this obviously should be reporting a proper error message rather than ICE'ing. Thanks for forwarding it along!

- Brooks Moses (GFortran maintainer)



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to