9 ms·
my understanding is that in fortran, if two arguments alias each other, it is UB. So it is not that fortran doesn't have aliasing, it is just that the optimizer
by gpderetta 3y ago
my understanding is that in fortran, if two arguments alias each other, it is UB. So it is not that fortran doesn't have aliasing, it is just that the optimizer assume that it doesn't (but don't quote me on this!).
- Bostonian 3y agoArguments are allowed to alias if they are both inputs that will not be changed in the function -- technically if they are both "intent(in)".
- pklausler 3y agoINTENT(IN) is not required to allow aliasing of unmodified dummy arguments.
- kergonath 3y agoYes, but in practice no compiler checks whether an argument with no INTENT is modified or not, or could alias with something else or not. So the compilers tend to trust the programmer. With INTENTS, it’s obvious and much easier to check.
- pklausler 3y agoDummy argument aliasing has nothing to do with INTENT.
- TheRealKing 3y agoI believe the NAG Fortran compiler does check for some aliasing scenarios if not all. The argument intent is irrelevant.