开发者

Are there Fortran compiler options for warning about write-after-write conflicts?

开发者 https://www.devze.com 2023-02-19 05:57 出处:网络
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 prog

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. ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消