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

Initialize stack variables

Mike_Rezny
Beginner
362 Views
Hi,
In the 11.1.038 documentation, the compiler option -ftrapuv is used to initialize stack variables to an unusual value.
Is there a way to specify the value that is used for integers, reals etc.?

regards
Mike
0 Kudos
2 Replies
Steven_L_Intel1
Employee
362 Views

No, there isn't. This has been requested before and continues to be considered. I consider -ftrapuv to be useless in its current form (and have said so to the developers). The original intent and description was to initialize floating point values to a NaN, but it didn't do that - the value chosen I think is hex CCCCCCCC - but I got the documentation changed.

Your effort would be best spent making sure that all variables are initialized before use. If you need help in finding these, you can turn on uninitialized variable checking, though it won't catch many cases. There is also the Source Checker (nee Static Verifier) which can be enabled in a build to report problems. Many of the issues it reports are "noise", but sometimes there's a gem in there.
0 Kudos
Mike_Rezny
Beginner
362 Views

No, there isn't. This has been requested before and continues to be considered. I consider -ftrapuv to be useless in its current form (and have said so to the developers). The original intent and description was to initialize floating point values to a NaN, but it didn't do that - the value chosen I think is hex CCCCCCCC - but I got the documentation changed.

Your effort would be best spent making sure that all variables are initialized before use. If you need help in finding these, you can turn on uninitialized variable checking, though it won't catch many cases. There is also the Source Checker (nee Static Verifier) which can be enabled in a build to report problems. Many of the issues it reports are "noise", but sometimes there's a gem in there.
Hi Steve,
many thanks for your reply.

One certainly needs a variety of ways of tracking down weird behaviour, especially with huge codes.

I do remember chasing a very stubborn bug with another compiler where initialising the stack to specific
value and searching for that value found the problem, when alll other avenues I tried had failed.

I just checked on 11.0.074 and indeed it is 0xcccccccc.

regards
Mike
0 Kudos
Reply