- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hello
Until now i was used that the initial value of integer is 0. (using CVF 6.6B)
Using IVF 9.0.019 the value looks different. Is this the way IVF works or is this a mistake?
Thanks in advance
Frank
Until now i was used that the initial value of integer is 0. (using CVF 6.6B)
Using IVF 9.0.019 the value looks different. Is this the way IVF works or is this a mistake?
Thanks in advance
Frank
コピーされたリンク
4 返答(返信)
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
The initial value is supposed to be undefined. You should not make any assumptions on it. On most compilers debug mode initializes variables to zero.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hello Ingo,
I cannot agree with you. Its is ok to say each variable has to set to an initial value inside the source, but in my view the compiler has to set each integer variable to 0 by definition(initial value).
Frank
I cannot agree with you. Its is ok to say each variable has to set to an initial value inside the source, but in my view the compiler has to set each integer variable to 0 by definition(initial value).
Frank
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
If you depend on default initialization, you must use options provided by individual compilers, such as ifort -Qsave -Qzero, until you have corrected your program.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi Frank,
it does not matter if you agree or not. According to the standard a fortran compiler does not have to assign an initial value to a variable.
So making assumptions about it is wrong or dangerous at best. If you rely on such a behaviour you need to use a non standard extensions of your compiler. This is probably the primary reason for programs that do not run in release mode but run flawessly in debug mode.
Default Initialization can be an overhead if your function gets called millions of times per second. According to the post by tim18 there is a way to enforce this for IVF. This does not change the fact that it is nonstandard and you will be in trouble again if you ever choose to use another compiler.
it does not matter if you agree or not. According to the standard a fortran compiler does not have to assign an initial value to a variable.
So making assumptions about it is wrong or dangerous at best. If you rely on such a behaviour you need to use a non standard extensions of your compiler. This is probably the primary reason for programs that do not run in release mode but run flawessly in debug mode.
Default Initialization can be an overhead if your function gets called millions of times per second. According to the post by tim18 there is a way to enforce this for IVF. This does not change the fact that it is nonstandard and you will be in trouble again if you ever choose to use another compiler.
