Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #164445

Re: Is the output of this program compiler dependent?

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: Is the output of this program compiler dependent?
Date 2022-01-17 15:26 +0100
Organization A noiseless patient Spider
Message-ID <ss3ua0$c7i$1@dont-email.me> (permalink)
References <ss2nci$a2k$1@gioia.aioe.org> <ss2okf$i0l$1@gioia.aioe.org> <ss36s7$ask$1@dont-email.me> <87fspm5yjb.fsf@bsb.me.uk>

Show all headers | View raw


On 17/01/2022 13:36, Ben Bacarisse wrote:
> David Brown <david.brown@hesbynett.no> writes:
> 
>> ("++i" is treated as "(i += 1)" or "(i = i + 1)", and there is a
>> sequence pointer at the assignment operator.)
> 
> No, there is no sequence point at assignment.
> 

Re-reading the section in the standards, I stand corrected.  Thank you.

I am trying to understand 6.5p2 here:

"""
If a side effect on a scalar object is unsequenced relative to either a
different side effect on the same scalar object or a value computation
using the value of the same scalar object, the behavior is undefined. If
there are multiple allowable orderings of the subexpressions of an
expression, the behavior is undefined if such an unsequenced side effect
occurs in any of the orderings. 85)
"""

The footnote says that this allows expressions like "i = i + 1;" while
rendering undefined "i = ++i + 1;".

(If there had been a sequence point at assignment, then this second
statement would have had defined behaviour.)

But in "i = i + 1;", the store to "i" is a side-effect on "i".  The
calculation "i + 1" is a value computation using the same scalar object.
 With no sequence point, these are unsequenced - and therefore
undefined.  What am I missing?

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Is the output of this program compiler dependent? Satan <satan@dot.com> - 2022-01-17 03:39 +0000
  Re: Is the output of this program compiler dependent? Richard Damon <Richard@Damon-Family.org> - 2022-01-16 23:19 -0500
  Re: Is the output of this program compiler dependent? James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-01-16 23:24 -0500
  Re: Is the output of this program compiler dependent? David Brown <david.brown@hesbynett.no> - 2022-01-17 08:46 +0100
    Re: Is the output of this program compiler dependent? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-01-17 12:36 +0000
      Re: Is the output of this program compiler dependent? David Brown <david.brown@hesbynett.no> - 2022-01-17 15:26 +0100
        Re: Is the output of this program compiler dependent? Öö Tiib <ootiib@hot.ee> - 2022-01-17 08:04 -0800
        Re: Is the output of this program compiler dependent? James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-01-17 15:51 -0500
    Re: Is the output of this program compiler dependent? James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-01-17 15:52 -0500

csiph-web