🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2939

Re: uninitialized++;

#2939
From: Norman Diamond
Date: Thu, 31 Dec 1992 03:41
28 lines
2301 bytes
In article <1992Dec30.172142.22789@taumet.com> mike@taumet.com (Mike Ball) writes:
>diamond@jit533.jit.dec.com (Norman Diamond) writes:
>>In article <9236508.13290@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>>>hbf@gandalf.uio.no (Hallvard B Furuseth) writes:
>>>>Can this fail  - on some machine?  - in ANSI?
>>  main () { int uninitialized; uninitialized += 0; return 0; }
>>I think this one is not allowed to fail.

>To quote from the standard., section 1.6
>"Undefined behavior - behavior, upon use of a nonportable or erroneous
>program construct, or erroneous data, or of indeterminately valued objects,
>for which the standard imposes no requirements."
>And 3.5.7
>"If an object that has automatic storage duration is not initialized
>explicitly, its value is indeterminate."
>Sounds like any use of the value, even adding 0, is undefined.

I would be happy to agree, but still am not quite convinced.  Is it true
that the standard imposes no requirements in this case?  Examples have been
posted for other problems in the past, where the values of variables were
indeterminate, but the standard still imposed some requirements; the values
had to be within some known set of possibilities.  Does an uninitialized
int variable also have to have a value within some known set of possibilities,
i.e. in the range INT_MIN to INT_MAX?  I believe the standard is unclear.
--
Norman Diamond                diamond@jit.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Pardon me?  Or do I have to commit a crime first?
Technical Details
Message-ID: <C03u97.C35@jrd.dec.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!decwrl!deccrl!news.crl.dec.com!dbased.nuo.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit533.jit.dec.com!diamond
References: <HBF.92Dec29211517@gandalf.uio.no> <9236508.13290@mulga.cs.mu.OZ.AU> <C02DDv.2Kw@jrd.dec.com> <1992Dec30.172142.22789@taumet.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!decwrl!deccrl!news.crl.dec.com!dbased.nuo.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit533.jit.dec.com!diamond
From: diamond@jit533.jit.dec.com (Norman Diamond)
Subject: Re: uninitialized++;
Message-ID: <C03u97.C35@jrd.dec.com>
Sender: usenet@jrd.dec.com (USENET News System)
Nntp-Posting-Host: jit533.jit.dec.com
Reply-To: diamond@jit.dec.com (Norman Diamond)
Organization: Digital Equipment Corporation Japan , Tokyo
References: <HBF.92Dec29211517@gandalf.uio.no> <9236508.13290@mulga.cs.mu.OZ.AU> <C02DDv.2Kw@jrd.dec.com> <1992Dec30.172142.22789@taumet.com>
Date: Thu, 31 Dec 1992 03:41:31 GMT
Lines: 28