preincrement

  • Thread starter prasoonthegreat
  • Start date
P

prasoonthegreat

int main( )
{
int i=1;
++i = 5;
}

Will the above code show Undefined Behaviour????
The value of i is changing only once between two sequence points or
twice??/???

I think twice,first after the increment and second after
assignment......but 5 will be assigned to incremented i in any
circumstances .....

So will it invoke UB???
 
N

Neelesh

int main( )
{
   int i=1;
  ++i = 5;

}

Will the above code show Undefined Behaviour????
The value of i is changing only once between two sequence points or
twice??/???

almost the same question was posted just a few hours ago, please have
a look at that
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/710ffcc66a03b843
I think twice,first after the increment and second after
assignment......but  5 will be assigned to incremented i in any
circumstances .....

Changing value of a variable more than once between two consecutive
sequence points results in undefined behaviour.
 

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

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top