Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Initial value of Integer in 9.0.019

tropfen
New Contributor I
771 Views
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
0 Kudos
4 Replies
ingo_berg
Beginner
771 Views
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.
0 Kudos
tropfen
New Contributor I
771 Views
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
0 Kudos
TimP
Honored Contributor III
771 Views
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.
0 Kudos
ingo_berg
Beginner
771 Views
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.
0 Kudos
Reply