compiler optimizing wrong?

T

Tim Rentsch

(e-mail address removed) writes:

[snip]
I think I have to view sequence points as linear. If they weren't then
how would one interpret the words 'previous' and 'subsequent' in this:

N869 5.1.2.3 paragraph 2

"Accessing a volatile object, modifying an object,
modifying a file, or calling a function that does any of

those operations are all side effects, which are changes
in the state of the execution environment. Evaluation of an
expression may produce side effects. At certain specified
points in the execution sequence called sequence points, all
side effects of previous evaluations shall be complete and
no side effects of subsequent evaluations shall have taken
place."

Sequence points (and evaluation orders in general) impose a
partial ordering, not a total ordering. Two sequence points in,
for example, the left and right branches of a '+' operator have
no ordering relationship to each other. The words 'previous' and
'subsequent' used in the Standard should be read approximately
as follows:

previous evaluations -- all evaluations guaranteed to start
/before/ the sequence point in question

subsequent evaluations -- all evaluations guaranteed to start
/after/ the sequence point in question

Some evaluations are not guaranteed to start either before
or after a particular sequence point; ie, they may start
"at the same time".

Two key points:

1. What is a 'previous sequence point' or 'subsequent
sequence point' _is always relative to the evaluation
of some expression_. The previous/next sequence points
for evaluating expression X may be different from the
previous/next sequence points for evaluating expression Y;
moreover it is possible to have any ordering relationships
(including no ordering) between those sequence points, as
long as they don't contradict the orderings pX < nX and
pY < nY.

2. Sequence points "exist" only in the abstract machine.
In an actual machine everything can be all mixed up,
under the well-known "as if" rule.
 
E

Eric Sosman

[...]
I think I have to view sequence points as linear. If they weren't then
how would one interpret the words 'previous' and 'subsequent' in this:

N869 5.1.2.3 paragraph 2
[...]

Sequence points are "linear" in the sense that any SP has a
predecessor and a successor, except for the very first and very
last of a chain. But it does not follow that there is a
before/after relation between every pair of SP's in a program!
For example,

f = (x ? y : z) + (u ? v : w);

There's an SP in each parenthesized expression, so we know that
x is evaluated strictly before whichever of y and z is chosen,
and u is before v or w. But there is no SP between x and u,
nor between y and u, nor between z and w, ... SP's are partially
ordered, not totally ordered.
 
Joined
Jul 5, 2011
Messages
2
Reaction score
0
So it is research on compilers they "can get for free?" Though I do
take your point that it is difficult to test compilers when you have to
buy them as they are not cheap.

On the other hand as most of the commercial compilers are heavily and
rigorously tested internally what is the advantage in letting a bunch of
academics have them?

In which case the report should have been entitled "GCC Volatiles Are
Miscompiled, and What to Do about It"

Chris, we've had this discussion before, where you assert that you know of a number of compilers that you don't think contain any volatile bugs, but then you won't provide any justification or examples. This kind of appeal to authority is not very useful to the rest of us.

Your assertion that we've only tested GCC is just wrong. Even in the 2008 paper we specifically mention CodeWarrior, Intel CC, Sun CC, and LLVM. We've tested a lot more compilers since then, including many of the embedded heavy hitters, and found bugs in all of them.

Better yet, our test case generation tool is being used by a number of compiler companies now, so hopefully the kind of bugs we can find will start to disappear.

No doubt our more recent results will bore you to tears since they focus on GCC and LLVM, but I'm happy with them:

http://www.cs.utah.edu/~regehr/papers/pldi11-preprint.pdf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,179
Latest member
pkhumanis73
Top