----- Original Message ----- From: "Dave Korn"
Sent: 31 October 2008 12:22
Subject: RE: cygwin g++ strictness

You are creating temporaries here.  If AddTwoInts modifies either of the
int references it has, that will only change the temporaries; x and y will
/not/ be modified.

You'll be surprised if you try it Dave....

int AddTwoInts (int& a, int& b)
{
   int x = a;
   int y = b;

   a = 6;  // Note this line

   return x + y;
}

int main()
{
int32_t  m=4;
gint  n=5;

   AddTwoInts ((int&)m, n);

   return 0;  // 'm' equals 6 by the time you get to this line !!
}

I was surprised too - but it works (!?!)

John


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to