473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

sequence point

Hi all,
This is not a question. Here I found a good article that discusses
sequence point in details:

http://www.embedded.com/shared/print...icleID=9900661

Nov 14 '05 #1
4 1889
ma*********@gmail.com wrote:
This is not a question. Here I found a good article that discusses
sequence point in details:

http://www.embedded.com/shared/print...icleID=9900661


It's not bad (I've seen much worse), but the situation is worse than
that writer seems to think. The code he discusses doesn't just invoke
unspecified behaviour because of order of evaluation issues, it actually
invokes full-blown undefined behaviour, because it modifies an object
_and_ reads it for another purpose, between sequence points. This means
that it cannot just call the function with unexpected values, it can
call the function with random values, with trap representations, not
call it at all, or print the lyrics to the Hedgehog Song and then abort.
Or just abort on a bus error without printing the Hedgehog Song, which
is a plausible effect of such code on suitable hardware, where the
arguments are evaluated in parallel.

Richard
Nov 14 '05 #2

Richard Bos wrote:
ma*********@gmail.com wrote:
This is not a question. Here I found a good article that discusses sequence point in details:
http://www.embedded.com/shared/print...icleID=9900661
It's not bad (I've seen much worse), but the situation is worse than
that writer seems to think. The code he discusses doesn't just invoke
unspecified behaviour because of order of evaluation issues, it actually invokes full-blown undefined behaviour, because it modifies an object
_and_ reads it for another purpose, between sequence points. This means that it cannot just call the function with unexpected values, it can
call the function with random values, with trap representations, not
call it at all, or print the lyrics to the Hedgehog Song and then abort. Or just abort on a bus error without printing the Hedgehog Song, which is a plausible effect of such code on suitable hardware, where the
arguments are evaluated in parallel.

Richard


I actually thought the article was pretty well written. From what I
could tell, the author points out what is undefined behavior and does a
decent job of explaining why it is undefined. Can you provide a
specific example of where the article is misleading, maybe I missed
something.

Rob Gamble

Nov 14 '05 #3
Richard Bos wrote:
ma*********@gmail.com wrote:
This is not a question. Here I found a good article that
discusses sequence point in details:
http://www.embedded.com/shared/print...icleID=9900661
It's not bad (I've seen much worse), but the situation is worse
than that writer seems to think. The code he discusses doesn't
just invoke unspecified behaviour because of order of evaluation
issues, it actually invokes full-blown undefined behaviour


The section you read was an earlier incorrect article by him,
and the current article is quoting the old article in order to
go on and correct it. The author should have been clearer about this.

Nov 14 '05 #4
"tigervamp" <rg*******@gmail.com> wrote:
Richard Bos wrote:
ma*********@gmail.com wrote:
http://www.embedded.com/shared/print...icleID=9900661
It's not bad (I've seen much worse), but the situation is worse than
that writer seems to think. The code he discusses doesn't just invoke
unspecified behaviour because of order of evaluation issues,


I actually thought the article was pretty well written.


Well, I certainly didn't think it was bad, and the information is
correct, if incomplete, but it looks like Old Wolf is right and the
article is confusingly laid out.
From what I
could tell, the author points out what is undefined behavior and does a
decent job of explaining why it is undefined. Can you provide a
specific example of where the article is misleading, maybe I missed
something.


From the first part of the article, it's easy to get the impression that
the author thinks UB can only lead to unexpected values. It can actually
lead to crashes, or worse, munged data.

Richard
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sensorflo | last post by:
After browsing though many newsgroups articels I'm still not shure how operator precedence, operator associativity, sequence points, side effects go together. Currently I have the following view: ...
4
by: j | last post by:
In a footnote in the c99 standard the following is labeled as undefined: a = i; And in the second clause of section 6.5 the following is stated: "Between the previous and next sequence...
3
by: sugaray | last post by:
Can somebody explain to me what is sequence point ? With few examples would be even better. Thanx for your help.
53
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an...
7
by: akarl | last post by:
Hi all, Why do I get a warning from gcc with the following program? $ cat test.c #include <stdio.h> int f(int n) { return n;
7
by: Kenneth Brody | last post by:
(From something brought up on "Help with array/pointer segmentation fault needed" thread.) Is "?" a sequence point? Or, more directly, is the following defined? /* Will "ptr" be guaranteed...
17
by: Frederick Gotham | last post by:
I know there's a sequence point at a comma, e.g.: int main(void) { int a = 1; a++, ++a, a *= 3, a <<= 4; /* Perfectly okay */ }
9
by: John Smith | last post by:
I've been playing with splint, which returns the following warning for the code below: statlib.c: (in function log_norm_pdf) statlib.c(1054,31): Expression has undefined behavior (left operand...
2
by: ais523 | last post by:
The program excerpt int i; char c; char* a= {"abc","def","ghi"}; /* ... */ i=0; c=a; obviously invokes undefined behaviour, because i is modified twice
4
by: Tomás Ó hÉilidhe | last post by:
I'm writing a program currently that was working perfectly until I decided to compile it with "-O3" in gcc (-O3 specifies optimisation of the third level). Anyway, I found the problem. I had the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.