Find The Bug

P

Pete Becker

Ron said:
BZZT. Caught myself here. Not undefined behavior as there are inherent
sequence points in the function calls. operator ++ is overloaded here.

Ah, that's the point. Okay, unspecified here. Undefined for builtin
types. Bad business either way.
 
R

Ron Natalie

Pete Becker said:
Where is the sequence point between the two increments?

They are done inside a SUBROUTINE. Operator++ is overloaded (these
are ENUMs). There is an sequence point after the value p is passed to the
function and when the value is returned.
 
O

osmium

David said:
cout << p << " " << p++ << " " << ++p << endl;
}

The output from g++ and several other compilers is _not_

0 0 2

as expected. In g++ it is

2 1 1

Did you allow for the fact that shift left has a lower precedence than
postfix ++ and prefix ++?
 
D

David Rasmussen

Kevin said:
Where is there a sequence point problem?

There is none, as others have pointed out. I meant the undefined
evaluation order problem.

/David
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top