Re: How to avoid undesired default values?
- From: Gordon Sande <g.sande@xxxxxxxxxxxxxxxx>
- Date: Tue, 28 Oct 2008 17:23:14 GMT
On 2008-10-28 12:33:50 -0300, Dave Allured <nospam@xxxxxxxxxx> said:
qquito wrote:...
In Fortran 90, you can use "implicit none" to prevent unspecified
variables from stealing into your codes. But how do you prevent
specified variables from taking on unassigned values?
In other words, I may specify an integer or real number but forget to
assign a value to it. Then this variable automatically assumes a value
which could be 0, or 1, or a number with an extremely large absolute
value.
I am using "gfortran" to compile my codes. Is there an option for the
compiler to tell me that certain variables need assigned values?
glen herrmannsfeldt wrote:...
Since compile time testing isn't usually reliable enough,
I believe he wants run-time testing. 'tell me' seems to indicate
more than just initializing the variables to known values.
Well, initializing reals to SNaN might work, but not for integer,
logical, or character.
I agree, though, that it is hard to be sure.
Is there any interest in adding run-time testing to gfortran?
Yes!
Simplest would be one compiler option to enable checking for signal
values, for all data types. Other desirable features would be:
* Including or excluding variables by name. (I think
part 1 is just what the OP requested.)
* Controlling init checking by individual data types.
* Options by data type for user-specified specify signal
values, instead of default signal values.
* Controlling init checking by individual program units.
* Controlling init checking within blocks of code.
* Controlling init checking at run time.
My thanks to anyone who puts their time in to implement any of this.
--Dave
There is the basic issue with debugging that you do not know where the
problem is. If you did know you would not be debugging. See the repeated
instructions to show the problem rather than describing it as the fact that
you have to ask shows that you do not know enough to describe it correctly.
If you knew enough to be able to use the extra features you would not need
them! Have you actually used a system with the capability to find a bug
that was more difficult than a seeded bug used to illustrate the capability?
When I read the list of features I thought that it was very clever but
reminded me of the chap who knew the prices of everything the values of
nothing.
.
- Follow-Ups:
- Re: How to avoid undesired default values?
- From: Dave Allured
- Re: How to avoid undesired default values?
- References:
- How to avoid undesired default values?
- From: qquito
- Re: How to avoid undesired default values?
- From: Steven G. Kargl
- Re: How to avoid undesired default values?
- From: glen herrmannsfeldt
- Re: How to avoid undesired default values?
- From: Steven G. Kargl
- Re: How to avoid undesired default values?
- From: Richard Maine
- Re: How to avoid undesired default values?
- From: glen herrmannsfeldt
- Re: How to avoid undesired default values?
- From: Dave Allured
- How to avoid undesired default values?
- Prev by Date: Re: return value as an allocatable array
- Next by Date: Re: test
- Previous by thread: Re: How to avoid undesired default values?
- Next by thread: Re: How to avoid undesired default values?
- Index(es):
Relevant Pages
|