Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Unspecified Behaviors in C90 - part 3 |
| Date | 2015-07-17 01:39 +0100 |
| Organization | go, ion artisan! |
| Message-ID | <mo9ipi$in4$1@dont-email.me> (permalink) |
| References | (4 earlier) <d5963c50-6159-4137-940d-f5d08a0a257e@googlegroups.com> <mo3mq2$8g9$1@dont-email.me> <8a2d57b6-f355-42c4-bf91-8980916925bb@googlegroups.com> <mo7gkg$afp$1@dont-email.me> <df8afa86-cc07-4c71-ae8a-57166e1ea508@googlegroups.com> |
On 17/07/15 01:15, David Kleinecke wrote: > On Wednesday, July 15, 2015 at 10:50:40 PM UTC-7, James Kuyper wrote: >> On 07/15/2015 10:46 PM, David Kleinecke wrote: >> > On Tuesday, July 14, 2015 at 12:11:39 PM UTC-7, James Kuyper wrote: >> ... >> >> So? With an modern compiler with an aggressive optimizer, by far the >> >> quickest way to predict what order will be used would be to compile the >> >> program, and find out which order was actually used by examining the >> >> generated program. >> > >> > But if the order matters the optimizer msut respect it or it is in >> > error. >> >> No - if the order is specified, the optimizer must respect it, or it is >> in error. > > That (apart for the "no") is exactly what I said. We are getting into > pointless squabbles about trivia. No, there is a slight but very significant difference. You wrote "if the order matters". He wrote "if the order is specified". Those are not the same thing. If the order doesn't matter, it doesn't matter. If it does matter, though, it's *your* job (as things stand at present) to ensure that things happen in the right order - and that's as it should be. (In fact, even if the order of evaluation were specified, it would still be your job - it's just that your job will be marginally easier if the evaluation order matches the order that you write the code, and marginally harder otherwise). James is saying that *if* the implementation were required to specify its order of evaluation, *then* it would be required to honour that spec. It is not a trivial distinction. It is a very important distinction. > >> If the order matters, but is not specified, it's the code >> that's in error, not the optimizer. The code is in error by reason of >> failing to specify the desired order. The C language provides all the >> constructs you need to force things to be evaluated in a specific order, >> if the order matters - all you have to do is use the right constructs. >> Example: if it's important that f() be executed before g(), don't write >> >> a = f() + g(); >> >> That would constitute a failure on your part to tell the compiler that >> the order is important. Here's how to tell it that: >> >> temp = f(); >> a = temp + g(); > > But suppose the compiler already did that but failed to tell you. Then you've lost nothing, and in fact you've gained clarity of expression. It's a better program, and it will survive a port to a compiler that /doesn't/ do that. -- Richard Heathfield Email: rjh at cpax dot org dot uk "Usenet is a strange place" - dmr 29 July 1999 Sig line 4 vacant - apply within
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-09 11:21 -0700
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-09 14:54 -0400
Re: Unspecified Behaviors in C90 - part 3 Richard Heathfield <rjh@cpax.org.uk> - 2015-07-09 21:38 +0100
Re: Unspecified Behaviors in C90 - part 3 raltbos@xs4all.nl (Richard Bos) - 2015-07-13 21:22 +0000
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-14 08:21 -0700
Re: Unspecified Behaviors in C90 - part 3 Keith Thompson <kst-u@mib.org> - 2015-07-14 08:48 -0700
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-14 09:33 -0700
Re: Unspecified Behaviors in C90 - part 3 Richard Heathfield <rjh@cpax.org.uk> - 2015-07-14 18:08 +0100
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-15 19:38 -0700
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-16 00:47 -0400
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-16 17:10 -0700
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-16 21:17 -0400
Re: Unspecified Behaviors in C90 - part 3 maddoxr@acm.org - 2015-07-17 07:43 -0700
Re: Unspecified Behaviors in C90 - part 3 Richard Heathfield <rjh@cpax.org.uk> - 2015-07-16 09:35 +0100
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-16 17:18 -0700
Re: Unspecified Behaviors in C90 - part 3 Richard Heathfield <rjh@cpax.org.uk> - 2015-07-17 01:45 +0100
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-16 21:19 -0400
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-17 12:14 -0400
Re: Unspecified Behaviors in C90 - part 3 Keith Thompson <kst-u@mib.org> - 2015-07-17 11:00 -0700
Re: Unspecified Behaviors in C90 - part 3 raltbos@xs4all.nl (Richard Bos) - 2015-07-19 21:24 +0000
Re: Unspecified Behaviors in C90 - part 3 Keith Thompson <kst-u@mib.org> - 2015-07-16 07:40 -0700
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-16 17:20 -0700
Re: Unspecified Behaviors in C90 - part 3 Richard Heathfield <rjh@cpax.org.uk> - 2015-07-17 01:49 +0100
Re: Unspecified Behaviors in C90 - part 3 Keith Thompson <kst-u@mib.org> - 2015-07-14 11:23 -0700
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-14 15:11 -0400
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-15 19:46 -0700
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-16 01:50 -0400
Re: Unspecified Behaviors in C90 - part 3 David Kleinecke <dkleinecke@gmail.com> - 2015-07-16 17:15 -0700
Re: Unspecified Behaviors in C90 - part 3 Richard Heathfield <rjh@cpax.org.uk> - 2015-07-17 01:39 +0100
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-16 22:26 -0400
Re: Unspecified Behaviors in C90 - part 3 raltbos@xs4all.nl (Richard Bos) - 2015-07-19 21:22 +0000
Re: Unspecified Behaviors in C90 - part 3 James Kuyper <jameskuyper@verizon.net> - 2015-07-19 17:57 -0400
csiph-web