[Bug c/59264] New: Incorrect order of execution on increament/decrement operator
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59264 Bug ID: 59264 Summary: Incorrect order of execution on increament/decrement operator Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: smaheshs41 at gmail dot com Created attachment 31281 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31281&action=edit The Order of execution of the code is not working properly in the 2nd & 3rd condition the expected output is 13 but 11 but it works correctly in 1st condition and the result is 13 As in the program stated it works fine when we have two increament/deacrement operator and one arithmetic operator(+). But, when we try the same thing with three increament/deacrement operator and two arithmetic operator(+) out off three conditions only for one condition the code gets executed correctly for the remaining two conditions it gives incorrect output.
[Bug c/59264] Incorrect order of execution on increament/decrement operator
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59264 --- Comment #3 from Mahesh S --- but it gets executed correctly for 1st condition why not for 2nd and 3rd On Sat, Nov 23, 2013 at 10:36 PM, redi at gcc dot gnu.org < gcc-bugzi...@gcc.gnu.org> wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59264 > > Jonathan Wakely changed: > >What|Removed |Added > > > Status|UNCONFIRMED |RESOLVED > Resolution|--- |INVALID > > --- Comment #2 from Jonathan Wakely --- > Instead of reporting a bug, try turning warnings on and fixing them, the > compiler tells you what's wrong with your code: > > t.c:2:6: warning: return type of ‘main’ is not ‘int’ [-Wmain] > void main() > ^ > t.c: In function ‘main’: > t.c:5:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > i=++i + ++i + i++; >^ > t.c:5:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > t.c:5:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > t.c:8:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > i=i++ + ++i + ++i; >^ > t.c:8:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > t.c:8:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > t.c:11:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > i=++i + i++ + ++i; >^ > t.c:11:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > t.c:11:3: warning: operation on ‘i’ may be undefined [-Wsequence-point] > > -- > You are receiving this mail because: > You reported the bug. >
[Bug c/59264] Incorrect order of execution on increament/decrement operator
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59264 --- Comment #5 from Mahesh S --- [Bug c/59264] Incorrect order of execution on increament/decrement operator But it works correctly in Turbo C and Borland C compiler why not in gcc On Sat, Nov 23, 2013 at 11:23 PM, ebotcazou at gcc dot gnu.org < gcc-bugzi...@gcc.gnu.org> wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59264 > > Eric Botcazou changed: > >What|Removed |Added > > > CC||ebotcazou at gcc dot > gnu.org > > --- Comment #4 from Eric Botcazou --- > > but it gets executed correctly for 1st condition why not for 2nd and 3rd > > Both executions are correct since the code has undefined behavior. > > -- > You are receiving this mail because: > You reported the bug. >