[Bug c/50425] precedence rule for pre/post increamet/decreament and effect of white spaces

2011-09-16 Thread grj017 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50425

Ganga Jaiswal grj017 at gmail dot com changed:

   What|Removed |Added

 Status|RESOLVED|VERIFIED

--- Comment #2 from Ganga Jaiswal grj017 at gmail dot com 2011-09-16 06:25:27 
UTC ---
Thanks Andy.


[Bug c/50425] New: precedence rule for pre/post increamet/decreament and effect of white spaces

2011-09-15 Thread grj017 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50425

 Bug #: 50425
   Summary: precedence rule for pre/post increamet/decreament and
effect of white spaces
Classification: Unclassified
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: grj...@gmail.com


Hi,
I was trying to understand precedence of pre/post increment/decrement
operators.
But it seems to be very confusing. According to precedence rule pre increment
has higher precedence than addition(+) and lower precedence than post
lineament.
 But when I use any expression like j= i + ++i + i + ++i; according to
precedence rule pre icrements will be performed first and then remaining
statement. suppose value of i=2, according to precedence rule pre increments
will be performed first and then addition. So after two pre increments value of
i becomes four and this value should be used in evaluation of complete
statement and it should be 16 but it is not. What is correct rule of precedence
in this case ??
Similarly in C, generally white spaces does not make any sense but in following
case they are they are behaving differently.consider following statements:
j = i +++ i;
j= i++ + i;
j=i + ++i;
j=i + + + i;
Please let me know, how are white space treated in this case? please follow a
consistent rule. Also clarify precedence rule of these operators.