Article View: comp.std.c
Article #4519Re: Statements, sequence points and execution order
From: B. Wiecek
Date: Sun, 31 Dec 1995 01:10
Date: Sun, 31 Dec 1995 01:10
40 lines
2005 bytes
2005 bytes
In article <30e5c15b.10973056@nntp.ix.netcom.com>, miker3@ix.netcom.com says... [snip] >As your program stands, it crashes because you are dereferencing a >null pointer. That results in undefined behavior, so you can't count >on anything. In principle, the compiler could reorder the calls. True, a compiler could detect it and produce code to print only one message eg. "Due to the problem with the programmer this program refuses to run." :) And that would be conforming. (leaving aside the quality of implementation) >However, there are conforming programs for which calling the function >after the printf() would result in different output (e.g., if it does >any output to stdout), and it would be illegal for the compiler to ^^^^^^^^^^^^^^^^^^^^^ That would make the two functions dependent. >change the order of the calls for such programs. It's unlikely that a >compiler could tell the difference, so I doubt if the order of the >function calls would be changed. As Jutta Degener (jutta@cs.tu-berlin.de) posted, the minimal requrements do allow reordering (including function calls) of statemets with no dependencies, and do regulate interactive I/O. It's just enough to allow aggresive optimizations, and keep the resulting code conforming. An undefined behaviour may show the optimizations, but then the program itself is 'non-conforming' (not to use word "garbage":), so it doesn't matter. >Michael M Rubenstein Thank you, B. Wiecek wiecek@ee.ualberta.ca --
Technical Details
Message-ID:
<4c4nuk$15ki@pulp.ucs.ualberta.ca>Path:
arc1-ca.pugleaf.net!rover.ucs.ualberta.ca!newsReferences:
<4c45oc$1sc8@pulp.ucs.ualberta.ca> <30e5c15b.10973056@nntp.ix.netcom.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!rover.ucs.ualberta.ca!news From: wiecek@ee.ualberta.ca (B. Wiecek) Newsgroups: comp.std.c Subject: Re: Statements, sequence points and execution order Date: 31 Dec 1995 01:10:44 GMT Organization: UA Message-ID: <4c4nuk$15ki@pulp.ucs.ualberta.ca> References: <4c45oc$1sc8@pulp.ucs.ualberta.ca> <30e5c15b.10973056@nntp.ix.netcom.com> NNTP-Posting-Host: vaclab.ee.ualberta.ca Mime-Version: 1.0 Content-Type: Text/Plain; charset=US-ASCII X-Newsreader: WinVN 0.99.7