Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is this undefined behavior??

Reply
Thread Tools

Is this undefined behavior??

 
 
saurabh29789
Guest
Posts: n/a
 
      06-06-2009
Here is a C++ code snippet :

{
int i = 10;

++i = 2;

}


Would the statement 2 invoke UB ??

PS : I think yes, it should, because i is being changed twice between
2 consecutive sequence points.
 
Reply With Quote
 
 
 
 
Bart van Ingen Schenau
Guest
Posts: n/a
 
      06-06-2009
saurabh29789 wrote:

> Here is a C++ code snippet :
>
> {
> int i = 10;
>
> ++i = 2;
>
> }
>
>
> Would the statement 2 invoke UB ??


Yes.

>
> PS : I think yes, it should, because i is being changed twice between
> 2 consecutive sequence points.


Your analysis is correct.

Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://c-faq.com/
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
typeof x == 'undefined' or x == undefined? -Lost Javascript 13 01-31-2007 12:04 AM
undefined vs. undefined (was: new Array() vs []) VK Javascript 45 09-12-2006 05:26 PM
pass an undefined number of datasets Andreas VHDL 5 05-31-2005 06:06 PM
undefined behavior or not undefined behavior? That is the question Mantorok Redgormor C Programming 70 02-17-2004 02:46 PM
NET::NNTP Undefined value error Gene Mat Perl 0 07-07-2003 11:38 PM



Advertisments