🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #51424

Re: Is there a way to initialize stack variables to NaN?

#51424
From: Jivano
Date: Mon, 31 May 1993 19:27
51 lines
2805 bytes
In <1rggar$hbu@nz12.rz.uni-karlsruhe.de> ig25@fg30.rz.uni-karlsruhe.de (Thomas Koenig) writes:

>Hello, gcc - world;

Hi Thomas,

>is there a way to initialize variables allocated on the stack to
>signalling NaN's on those architectures which support them?

>The reason I'm asking is that I have some FORTRAN code which I
>want to use on my Linux box using f2c.  The code does depend
>on keeping values between subroutine calls (which is non - standard,
>but common in old programs), and I'd rather find this out by
>having the program die on me once for each variable than by
>getting subtly wrong results all the time.

What you want, you can get at compile time thru the warning
about possibly unitialized variables ( -Wuninitialized) when
you compile with optimization. The other way around in your case
you will never be sure, that your test cases covered all dump-
candidates, right ?

>If there is no way, I' selfishly suggest adding this to gcc as a
>debugging help (maybe to the malloc - call as well).

Yeah, I think, that's a great idea, but a lot of work. Just
consider how many diffrent possibilities you might need to get
the job done in a thorough and consistant way (pointer,
structures, integers, double floats etc. etc.). With malloc
your probably better off using your own debugging version, hmm ?
There are ready debugging packages around which do that for you.

And with these floating point variables I suggest you write
a small little macro or subroutine say: set_NAN (double *x);
- I mean if you really need it NOW ? (and in the routine
cast the double to something else to avoid floating point
instruction when accessing it).

My personal taste:

If you REALLY want a functioning program to be debugged easily,
rewrite the fortran code by hand (or at least read it - perhaps
loud - line by line). The best debugging package is your nose.

>Happy hacking

The same to you, too.
Jivano. jivano@samser.muc.de
-- 
jivano@samser.muc.de   Jivano, Sauwiese 12, 8031 Wessling  Phone: +49 8153 1321
- Signature Collectors Corner: Trading two opinions for one signature today. -
Technical Details
Message-ID: <C7wopz.4rA@samser.gold.muc.de>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!spool.mu.edu!nigel.msen.com!math.fu-berlin.de!fauern!lrz-muenchen.de!colin.muc.de!greenie!samser!jivano
References: <1rggar$hbu@nz12.rz.uni-karlsruhe.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,6002b9e23f04d8f3
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-06-01 09:26:08 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!spool.mu.edu!nigel.msen.com!math.fu-berlin.de!fauern!lrz-muenchen.de!colin.muc.de!greenie!samser!jivano
From: jivano@samser.gold.muc.de (Jivano)
Subject: Re: Is there a way to initialize stack variables to NaN?
Organization: SAM - Software Artists Munich GmbH
Date: Mon, 31 May 1993 19:27:34 GMT
Message-ID: <C7wopz.4rA@samser.gold.muc.de>
References: <1rggar$hbu@nz12.rz.uni-karlsruhe.de>
Lines: 51