Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And like in everything C, unlike Fortran, there is no way for the compiler to validate if restrict is being used properly.

Use it wrong, break the compiler assumptions and the bug hunting fun starts.



Mostly the compiler won't catch violation of the storage association rules. Toolpack had a useful tool for strict F77 code which was a boon fixing stuff not to break with the Alliant compiler, which was the first one the project I inherited used that took advantage of the optimization opportunity. Possibly Cray's would have done, but hadn't been used for a while at that point.

The fact that people won't believe the rules exist, is a continual source of bug hunting in Fortran unfortunately. At least restrict is visible.


How does Fortran enforce this, actually? Does it just not let you pass the same array to a function via multiple parameters?


Fortran didn't originally have pointers, and pointer based code is relatively rare in fortran, so making requirements about pointer aliasing doesn't have same potential to completely break your code that it does in c. The reason c can't actually restrict the restrict keywoard, is that the standard would break code!


The storage association rules have nothing to do with pointers like that. Code will typically break because arguments are passed with copy-in/copy-out semantics, not by reference.


It does, indeed, but that's not the only way to associate storage. Using INTENT to specify whether an array is updated is useful.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: