Are there Fortran compiler options for warning about write-after-write conflicts?
Let's say you have the following code:
INTEGER :: num_samples
num_samples = 10000
num_samples = 1
Obviously, the first num_samples = 10000
does nothing, and its existence probably indicates a programmer error (e.g., the programmer meant to comment out the following line, or vice-versa). Are there any Fortran compilers that will warn for such write-after-write errors, and if so what options turn on the warning?
(I'm also interested if there are C++ compilers with such warnings, and if there are Java IDEs that provide such warnings, 开发者_运维知识库but right now I'm focusing on the Fortran side of things.)
This is kind of strange question from my point of view. This write-after-write situation you mentioned is a logical error. Compilers detect mostly syntax errors. In some cases logical error may reveal themselves as syntax errors but not always.
A logical error means that you made a mistake in implementing your algorithm. You can notice it only upon testing. Or you can also try static program analysis (as steabert mentioned).
I'm also interested if there are C++ compilers with such warnings, and if there are Java IDEs that provide such warnings, but right now I'm focusing on the Fortran side of things.
Take a look at functional programming languages. Due to immutability write-after-write situation just can't happen. ;-)
精彩评论