You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Fortran there is no equivalence between logical and integer variables, so 0 is not a replacement for .false., and 1 does not replace .true.. Yet, some compilers (ifort) will happily compile if (1).
Example:
if (0) write(*, *) 'Test is false'if (1) write(*, *) 'Test is true'
A slightly more meaningful example
integer val
val =1if (val) write(*, *) 'Test is true'
This should be replaced by
integer val
val =1if (val > 0) write(*, *) 'Test is true'
The text was updated successfully, but these errors were encountered:
Your example perfectly aligns with the broader efforts to modernize Fortran. And indeed, as you've pointed out, although these conditional expressions may not break compilation, they certainly lead to confusion and maintenance challenges.
We'd love for you to open a PR proposing a check for this in the Open Catalog. You can follow the guidance in #36 for adding new entries. Of course, if you'd prefer, just let us know, and we'll be happy to handle it!
Thanks @inaki-amatria 🙂 I don't think that I've more time to work on this, so I'll be happy if you can take over. The same goes for the other issues that I've opened 😅
In Fortran there is no equivalence between logical and integer variables, so
0
is not a replacement for.false.
, and1
does not replace.true.
. Yet, some compilers (ifort) will happily compileif (1)
.Example:
A slightly more meaningful example
This should be replaced by
The text was updated successfully, but these errors were encountered: