Re:Lfortran: Modern interactive LLVM-based Fortran compiler
by 3836293648 on Monday August 28, 2023 @05:21PM
(#37300547)
This can be done in C, but not C++, though in practice all C++ compilers support it. It's the `restrict` keyword
Re:Lfortran: Modern interactive LLVM-based Fortran compiler
by nextaccountic on Tuesday August 29, 2023 @02:54AM
(#37304253)
> The burden is on the programmer to not associate these dummy arguments on a call with data that violate this requirement.
What happens when the programmer pass aliasing a and b? Will it cause UB, like in C if you violate the restrict keyword?
Re:Lfortran: Modern interactive LLVM-based Fortran compiler
by pklausler on Tuesday August 29, 2023 @11:32AM
(#37309424)
Fortran's standard doesn't use the term Undefined Behavior; instead, it states a requirement that an object modified via one dummy argument must not be modified or referenced via any other name. When a program violates that requirement, it's no longer conforming to the standard, and the language doesn't define what happens afterwards. In practice, you'll get bad results and a bad day of debugging.
Re:Lfortran: Modern interactive LLVM-based Fortran compiler
by nextaccountic on Wednesday August 30, 2023 @03:45AM
(#37318860)
> When a program violates that requirement, it's no longer conforming to the standard, and the language doesn't define what happens afterwards. In practice, you'll get bad results and a bad day of debugging.
This is just UB by another name
That's.. disappointing
Re:Lfortran: Modern interactive LLVM-based Fortran compiler
by pklausler on Wednesday August 30, 2023 @11:53AM
(#37324007)
Rewind your disappointed expectations back to Fortran II in the 1950's, the first Fortran with subprograms. The value proposition was this: if a programmer was willing to help the Fortran optimizer out by avoiding aliasing, the compiler would generate code that was usually fast enough to avoid the need to write in assembly. It was a great deal for the programmer at the time. Fortran succeeded not just because it allowed one to write more productively in a "high-level" language but because its compilers could optimize well enough that there was no significant performance cost to doing so. (And then its popularity allowed one to port Fortran code from one vendor's hardware to another.)
(This freedom from aliasing doesn't extend to Fortran's POINTER feature, nor does it apply to the ASSOCIATE construct, some compilers notwithstanding.)