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

Automatic initialization of numeric variables?

Leigh
Beginner
734 Views
Does Intel Fortran have a compiler option that forces static numeric variables to be initialised to zero?

I have seen the /Qzero and /Qtrapuv options. However, they don't seem to fit the bill.

Alternatively, is there an option to cause warning to be produced if a variable is used without having been initialised? I can understand that C compilers can do this because goto is rare in C. I'm not sure whether such a warning is possible in Fortran where goto might be present.

Thanks for your attention.

Leigh.
0 Kudos
1 Solution
netphilou31
New Contributor III
734 Views
Hi Leigh,

I think that you have to also use the /Qsave option (save local variables in static allocation ) with the /Qzero option. However you did not mention which version of the compiler you are using.

Concerning the use of local, uninitialized variables, the compiler shouldnormally give you some warning message.

Phil.

View solution in original post

0 Kudos
3 Replies
netphilou31
New Contributor III
735 Views
Hi Leigh,

I think that you have to also use the /Qsave option (save local variables in static allocation ) with the /Qzero option. However you did not mention which version of the compiler you are using.

Concerning the use of local, uninitialized variables, the compiler shouldnormally give you some warning message.

Phil.
0 Kudos
Leigh
Beginner
734 Views
Hi,

The version is 2011.0.14.

I should also say that the body of code I am working on is legacy code. These variables are also at the program level. Does /Qsave have an effect on those.

Thanks,
Leigh.
0 Kudos
Steven_L_Intel1
Employee
734 Views
The compiler offers run-time errors for uses of uninitialized local variables through /check:uninit. It has some limitations.

/Qtrapuv, in its current implementation, does nothing useful.
0 Kudos
Reply