From 3688855976018096224
X-Google-Thread: f78e5,174aa7b34b06a51
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 04 Dec 2005 12:10:02 -0600
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
From: brangdon@cix.co.uk (Dave Harris)
Newsgroups: comp.std.c++
Subject: Re: Is this really unspecified behavior?
Message-ID: <memo.20051204142625.2020A@brangdon.m>
References: <1132786459.216137.307610@z14g2000cwz.googlegroups.com>
Reply-To: brangdon@cix.co.uk
X-Orig-X-Trace: individual.net +ho+bBjJp9zQonpVR07AjQPVwNf16dJhuurZcX21RgV9A9kk8=
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Date: Sun,  4 Dec 2005 12:05:31 CST
Lines: 25
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-eOm4+o71150ayCUT5onML+8JzLUvPunZtdTi6L3eEek3Aqgub+R3VQ0wdEV2/10rVARG/42G2+mft55!Uv6itmMG0BHdQlcEaG7ARjlOAzNf54xa7sZ84xKbhoMw+Wnbw98kXgDSd4KP+AmgyOZ8hyBB2yIl!7aSjKMJRMRWF4qn28Tlz
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news1.google.com comp.std.c++:2667

pongba@gmail.com () wrote (abridged):
> It's just that I couldn't believe this little simple expression
> has undefined behavior, though, I think you were right anyway.

If you think of i as being stored as two words that are manipulated 
separately, then it becomes easier to see. You might get the high word of 
the new value and the low word of the old value. For example:

     i = 0x1000ffff;
     i = i++;

might yield i == 0x1001ffff, which is different to (and much bigger 
than) any value that you would consider "correct". If i is a pointer, this 
could point to memory the application doesn't own, which could lead to a 
hardware fault even if *i is not accessed. And ints can have trapping 
values too.

-- Dave Harris, Nottingham, UK.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



