public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50425] New: precedence rule for pre/post increamet/decreament and effect of white spaces
@ 2011-09-15 18:21 grj017 at gmail dot com
  2011-09-15 18:33 ` [Bug c/50425] " pinskia at gcc dot gnu.org
  2011-09-16  7:13 ` grj017 at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: grj017 at gmail dot com @ 2011-09-15 18:21 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: grj017@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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/50425] precedence rule for pre/post increamet/decreament and effect of white spaces
  2011-09-15 18:21 [Bug c/50425] New: precedence rule for pre/post increamet/decreament and effect of white spaces grj017 at gmail dot com
@ 2011-09-15 18:33 ` pinskia at gcc dot gnu.org
  2011-09-16  7:13 ` grj017 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-09-15 18:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50425

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-09-15 18:21:31 UTC ---
This is not a good place to learn C/C++ really.  But anyways the order of
evulating of the operands of + is not specified and could happen in either
order as there is no sequence point.  Read http://c-faq.com/expr/seqpoints.html
.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/50425] precedence rule for pre/post increamet/decreament and effect of white spaces
  2011-09-15 18:21 [Bug c/50425] New: precedence rule for pre/post increamet/decreament and effect of white spaces grj017 at gmail dot com
  2011-09-15 18:33 ` [Bug c/50425] " pinskia at gcc dot gnu.org
@ 2011-09-16  7:13 ` grj017 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: grj017 at gmail dot com @ 2011-09-16  7:13 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-16  6:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-15 18:21 [Bug c/50425] New: precedence rule for pre/post increamet/decreament and effect of white spaces grj017 at gmail dot com
2011-09-15 18:33 ` [Bug c/50425] " pinskia at gcc dot gnu.org
2011-09-16  7:13 ` grj017 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).