473,473 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1892
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.