且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Fortran是否具有未定义的行为?

更新时间:2023-11-13 08:40:22

是的.只是被称为不同.您可以做很多事情,并使您的代码不符合标准的要求,因此不需要处理器(编译器)诊断此类不符合项(当然,必须进行许多偏离)被诊断).通常情况将类似于C的未定义行为(例如访问数组越界,有符号整数溢出等).我们只是说该代码不符合标准,这意味着该标准并未规定此类代码的结果.此类代码未涵盖在标准中,因此,如果某些编译器(处理器)对它进行编译并且您运行了它,则任何事情都可能会导致.

Yes, it has. It is just called differently. There are many things that you could do and will make your code not standard conforming, for which there is no requirement to for the processor (compiler) to diagnose such non-conformance (of course, many deviations must be diagnosed). Often the situations will be similar to C undefined-behaviour one (like accesing an array out-of-bounds, signed integer overflow,...). We just say that the code is not standard conforming, that means the standard does not prescribe the outcome of such a code. Such code is not covered but the standard and so anything can result if some compiler (processor) does compile it and you do run it.

依赖处理器的行为不同,它是标准的,仅依赖于实现.

That is different from processor dependent behaviour, that one is standard and just implementation dependent.

只需在***上进行搜索即可为您提供大量示例.就像是否将同一实体传递给具有不同意图未定义行为的参数?

Just searching here at *** should give you plenty of examples. Like Is passing the same entity to arguments with different intent undefined behavior? How do Fortran and MPI_Reduce deal with integer overflow?