Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: trapping NaN to find uninitialised variables? |
| Date | 2015-07-23 07:56 -0700 |
| Organization | None to speak of |
| Message-ID | <lnmvymzzvl.fsf@kst-u.example.com> (permalink) |
| References | <636d6775-affc-4f24-9394-f8b190c5174a@googlegroups.com> |
pedro1492@lycos.com writes:
> Open64 has flag -trapuv and gcc has -finit-real=nan
> The claim is that variables are created NaN, so if your program does
> not initialise them before use, then it bites you on the arse.
[...]
What is the context for that claim?
C never guarantees that floating-point objects are initialized
to NaN.
An FP object with static storage duration and no explicit
initialization is initialized to 0.0. An object with automatic
storage duration, or allocated with malloc, is typically initialized
to whatever garbage was in that chunk of memory before it was
allocated. An FP object allocated with calloc is initialized to
all-bits-zero, which is *probably* 0.0, but that's not guaranteed.
An implementation could make additional guarantees. As for gcc, the
-finit-real=nan option is implemented only for Fortran, not for C.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
trapping NaN to find uninitialised variables? pedro1492@lycos.com - 2015-07-23 01:42 -0700
Re: trapping NaN to find uninitialised variables? Bartc <bc@freeuk.com> - 2015-07-23 10:35 +0100
Re: trapping NaN to find uninitialised variables? Robert Wessel <robertwessel2@yahoo.com> - 2015-07-23 04:51 -0500
Re: trapping NaN to find uninitialised variables? raltbos@xs4all.nl (Richard Bos) - 2015-07-23 11:03 +0000
Re: trapping NaN to find uninitialised variables? Keith Thompson <kst-u@mib.org> - 2015-07-23 07:56 -0700
Re: trapping NaN to find uninitialised variables? pedro1492@lycos.com - 2015-07-29 05:39 -0700
Re: trapping NaN to find uninitialised variables? Keith Thompson <kst-u@mib.org> - 2015-07-29 08:58 -0700
Re: trapping NaN to find uninitialised variables? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-07-23 10:39 -0700
csiph-web