🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2872

Re: Undefined versus unspecified

#2872
From: Jerry Coffin
Date: Thu, 07 Dec 1995 16:00
37 lines
2095 bytes
jcoffin@rmii.com (Jerry Coffin) wrote:

...an article that somehow came out totally munged...

[ talking about unspecified vs. undefined behavior... ] 

>Not really.  Consider a real example of unspecified behavior:

>	a = b + c + d;

[ article body that didn't fit the example _at__all_  elided ] 

Okay, the order of evaluation here is unspecified.  Depending on
circumstances, we may even be able to detect differences due to
different orders of evaluation. (e.g. all are doubles, c and d are both
much smaller than b.  Each of c and d being added to b might
individually have no effect, but adding c and d first might produce a
number large enough to affect the value of b.)

However, despite the fact that this is unspecified behavior, as long as
the magnitudes are such that overflow is impossible, the compiler has no
option to produce code that blows up or causes other behavior unrelated
to adding some numbers together.  It's only leeway in the matter may, at
most, cause a slightly different numerical result.
    Later,
    Jerry.

/* I can barely express my own opinions; I certainly can't
 * express anybody else's.
 *
 * The universe is a figment of its own imagination.
 */


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <4a60en$at2@natasha.rmii.com>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <MATT.95Nov30185128@cyclops5.berkeley.edu> <ACE4F57196681C2631@corf.demon.co.uk> <49uf3e$hpr@gabi.gabi-soft.fr> <4a2nvl$nq@natasha.rmii.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: jcoffin@rmii.com (Jerry Coffin)
Newsgroups: comp.std.c++
Subject: Re: Undefined versus unspecified
Date: 7 Dec 1995 16:00:02 GMT
Organization: TAEUS
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4a60en$at2@natasha.rmii.com>
References: <MATT.95Nov30185128@cyclops5.berkeley.edu> <ACE4F57196681C2631@corf.demon.co.uk> <49uf3e$hpr@gabi.gabi-soft.fr> <4a2nvl$nq@natasha.rmii.com>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: slip8140.rmii.com
X-Newsreader: Forte Free Agent 1.0.82
Content-Length: 1191
X-Lines: 33
Originator: clamage@taumet