Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: what is the right value about a = a++; |
| Date | 2012-02-09 01:05 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <20120208161852.146@kylheku.com> (permalink) |
| References | (3 earlier) <8uh1j7t7tkqu9jdu920cgurbnrn2hi3anl@4ax.com> <20120207090433.476@kylheku.com> <qdadndbp0NhHGKzSnZ2dnUVZ_uCdnZ2d@bestweb.net> <4f319955.234650417@text.giganews.com> <27WdnWl1SYYBQK_SnZ2dnUVZ_q2dnZ2d@bestweb.net> |
On 2012-02-08, Kenneth Brody <kenbrody@spamcop.net> wrote: > On 2/7/2012 4:50 PM, Richard Harter wrote: >> On Tue, 07 Feb 2012 15:12:53 -0500, Kenneth Brody >> <kenbrody@spamcop.net> wrote: >> >>> On 2/7/2012 3:15 AM, Kaz Kylheku wrote: >>>> On 2012-02-07, Barry Schwarz<schwarzb@dqel.com> wrote: >>>>> On Mon, 6 Feb 2012 02:33:24 -0800 (PST), lujnan<lujnan@gmail.com> >>>>> wrote: >>>>> >>>>>> On Feb 6, 5:45 pm, bert<bert.hutchi...@btinternet.com> wrote: >>>>>>> On Monday, February 6, 2012 8:10:00 AM UTC, lujnan wrote: >>>>>>>> b = a = a++; >>> [...] >>>> I don't want diagnostics; I want strict left to right evaluation order >>>> of operands and subexpressions that complete their side effects before >>>> yielding a value. >>> >>> So, what you are really saying, is you want to eliminate most of C's >>> optimization abilities, by restricting the order in which the expression >>> *must* be evaluated, and side effects *must* be completed? >> >> Well, no, he isn't saying any such thing. You just made it up. The >> fact that evaluation order in C is left to the compilers has very >> little to do with optimization; it is a historical artifact that came >> from endorsing existing practice when the ANSI standard was put >> together. Existing practice then was that compiler writers could do >> evaluations in whatever they pleased and they did. > > Well, not having access to the Standards committee, I can only speculate. > However, if evaluation order were the only thing at stake here, things would > have been left as "unspecified" rather than "undefined". Last I looked, the order is in fact unspecified. But then what is undefined is the multiple uses of the same object. So for instance f(g(), h()); is not undefined behavior, but unspecified. We don't know whether g is called first or h, but there are only two possibilities. In /practice/ there is no difference. Unspecified, undefined: it all translates to hidden bugs in code that are not caught by your regression test suite---even if that code has 100% coverage! > In the 30+ years of programming in C, I don't believe I've ever had the need > to write code which depended on side-effects being completed in "the right > order" within a single statement. I.e. you have written plenty of code with multiple side effects, but you're sure that you didn't botch it. > Whether that's because I know that > there's no such thing as "the right order", or because I never came across a > scenario where that might be useful, I cannot say, but I'm leaning towards > the latter. I'm not so confident. After 30 years of coding, I'm still making coding mistakes (even syntax!). I catch these with the help of the compiler, by reviewing code, by test coverage, or sometimes with the help of other people. These evaluation order issues fall into a category that is not caught by tools, and not even by perfect test coverage, because a test case could simply validate that the expected behavior is happening on the given target machine and compiler. I can't justify a belief that the mistakes I make are always, by good luck, in categories that are caught by the compiler, or by test coverage. Of course I haven't /knowingly/ stuffed multiple side effects into an expression such that their order is critical to the correct outcome, for what that is worth.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
what is the right value about a = a++; lujnan <lujnan@gmail.com> - 2012-02-06 00:10 -0800
Re: what is the right value about a = a++; Ruben Mikkonen <camu.umac@gmail.com> - 2012-02-06 00:28 -0800
Re: what is the right value about a = a++; Keith Thompson <kst-u@mib.org> - 2012-02-06 21:27 -0800
Re: what is the right value about a = a++; Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-02-06 22:39 -0700
Re: what is the right value about a = a++; bert <bert.hutchings@btinternet.com> - 2012-02-06 01:45 -0800
Re: what is the right value about a = a++; lujnan <lujnan@gmail.com> - 2012-02-06 02:33 -0800
Re: what is the right value about a = a++; "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-02-06 14:57 -0800
Re: what is the right value about a = a++; Barry Schwarz <schwarzb@dqel.com> - 2012-02-06 22:50 -0800
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 08:15 +0000
Re: what is the right value about a = a++; lujnan <lujnan@gmail.com> - 2012-02-07 00:31 -0800
Re: what is the right value about a = a++; Keith Thompson <kst-u@mib.org> - 2012-02-07 09:07 -0800
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 17:31 +0000
Re: what is the right value about a = a++; Joshua Maurice <joshuamaurice@gmail.com> - 2012-02-09 17:50 -0800
Re: what is the right value about a = a++; Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-02-21 23:42 +0200
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-22 04:28 +0000
Re: what is the right value about a = a++; Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-02-25 00:01 +0200
Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-25 02:25 -0500
Re: what is the right value about a = a++; Ike Naar <ike@iceland.freeshell.org> - 2012-02-25 09:00 +0000
Re: what is the right value about a = a++; Philip Lantz <prl@canterey.us> - 2012-02-25 11:13 -0800
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-25 19:34 +0000
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-25 16:51 -0500
Re: what is the right value about a = a++; lawrence.jones@siemens.com - 2012-02-27 16:12 -0500
Re: what is the right value about a = a++; Ike Naar <ike@iceland.freeshell.org> - 2012-02-27 22:42 +0000
Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-27 18:54 -0500
Re: what is the right value about a = a++; Barry Schwarz <schwarzb@dqel.com> - 2012-02-07 09:26 -0800
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-07 15:12 -0500
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-07 21:50 +0000
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-07 16:51 -0600
Re: what is the right value about a = a++; Robert Wessel <robertwessel2@yahoo.com> - 2012-02-07 22:49 -0600
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-08 14:08 -0600
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 00:18 +0000
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 13:06 -0500
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-09 13:58 -0600
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 23:52 +0000
Re: what is the right value about a = a++; jgk@panix.com (Joe keane) - 2012-02-10 21:45 +0000
Re: what is the right value about a = a++; Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-02-22 00:09 +0200
Re: what is the right value about a = a++; Robert Wessel <robertwessel2@yahoo.com> - 2012-02-08 22:35 -0600
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-08 15:42 -0500
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-08 14:47 +0000
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-08 14:29 -0600
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:27 +0000
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-09 23:10 -0500
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 09:11 +0000
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 07:26 -0500
Re: what is the right value about a = a++; Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-10 13:12 +0000
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 11:07 -0500
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 16:27 +0000
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 12:17 -0500
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 12:09 -0600
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 18:17 -0500
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-11 10:15 +0000
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-13 16:04 -0500
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 12:30 -0600
Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-09 21:30 -0500
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:48 +0000
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-10 09:49 +0000
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 00:15 +0000
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 12:49 -0500
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 23:51 +0000
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-08 15:39 -0500
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 01:05 +0000
Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-09 23:24 -0500
Re: what is the right value about a = a++; Jens Gustedt <jens.gustedt@loria.fr> - 2012-02-10 16:58 +0100
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-10 23:32 +0000
Re: what is the right value about a = a++; John Bode <jfbode1029@gmail.com> - 2012-02-08 17:41 -0800
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-08 22:25 -0500
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 13:15 -0500
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 23:57 +0000
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 11:15 -0500
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 11:58 -0600
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 18:14 -0500
Re: what is the right value about a = a++; Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-10 22:43 +0000
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 11:53 -0600
Re: what is the right value about a = a++; Joshua Maurice <joshuamaurice@gmail.com> - 2012-02-10 15:19 -0800
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:32 +0000
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-09 23:13 -0500
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 09:34 +0000
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 07:32 -0500
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-10 22:24 +0000
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-10 11:35 -0500
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 12:23 -0500
Re: what is the right value about a = a++; falk@rahul.net (Edward A. Falk) - 2012-02-08 20:40 +0000
Re: what is the right value about a = a++; Keith Thompson <kst-u@mib.org> - 2012-02-08 15:00 -0800
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 01:10 +0000
Re: what is the right value about a = a++; 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-09 20:43 -0800
Re: what is the right value about a = a++; Robert Wessel <robertwessel2@yahoo.com> - 2012-02-09 23:36 -0600
Re: what is the right value about a = a++; cri@tiac.net (Richard Harter) - 2012-02-10 02:40 +0000
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-09 23:17 -0500
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-08 23:49 +0000
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-08 23:42 +0000
Re: what is the right value about a = a++; blp@cs.stanford.edu (Ben Pfaff) - 2012-02-07 12:09 -0800
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-07 07:42 -0500
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 17:21 +0000
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-07 15:24 -0600
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 01:27 +0000
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 21:57 -0600
Re: what is the right value about a = a++; "Joel C. Salomon" <joelcsalomon@gmail.com> - 2012-02-08 01:00 -0500
Re: what is the right value about a = a++; falk@rahul.net (Edward A. Falk) - 2012-02-08 20:33 +0000
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 02:05 +0000
Re: what is the right value about a = a++; Markus Wichmann <nullplan@gmx.net> - 2012-02-09 09:28 +0100
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 10:21 +0000
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-09 11:38 +0000
Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-10 00:03 -0500
Re: what is the right value about a = a++; Philip Lantz <prl@canterey.us> - 2012-02-10 01:15 -0800
Re: what is the right value about a = a++; Kenneth Brody <kenbrody@spamcop.net> - 2012-02-09 13:22 -0500
Re: what is the right value about a = a++; Slash QB <slashqb@gmail.com> - 2012-02-06 02:35 -0800
Re: what is the right value about a = a++; Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-07 03:07 -0800
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-07 15:19 -0600
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-07 17:00 -0500
Re: what is the right value about a = a++; Stephen Sprunk <stephen@sprunk.org> - 2012-02-10 12:05 -0600
Re: what is the right value about a = a++; James Kuyper <jameskuyper@verizon.net> - 2012-02-10 13:46 -0500
Re: what is the right value about a = a++; Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-02-06 22:37 -0700
Re: what is the right value about a = a++; Kaz Kylheku <kaz@kylheku.com> - 2012-02-07 07:22 +0000
Re: what is the right value about a = a++; Shao Miller <sha0.miller@gmail.com> - 2012-02-07 01:18 -0500
csiph-web