[Bug c/53656] New: sequence point bug

2012-06-13 Thread alexcheremkhin at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53656

 Bug #: 53656
   Summary: sequence point bug
Classification: Unclassified
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: alexcheremk...@gmail.com


Created attachment 27614
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27614
source code

$gcc -v

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Целевая архитектура: i686-pc-linux-gnu
Параметры конфигурации: ./configure
Модель многопоточности: posix
gcc версия 4.6.0 (GCC) 

Optimization options do not matter (result is the same).

Source code:

/* bug.c */

#include 

int x = 0;

int f()
{
return x++;
}

int main()
{
int y = x++ + f();
printf("x=%d\n", x);
return 0;
}
--
The program should have printed 'x=2', but prints 'x=1'.
It looks like the variable x had been read to a register before call of f(),
and incremented after the call.
The function call makes a sequence point, so the behaviuor is not correct.

Alexey Cheremkhin; Compiler Department, KM211.
a...@km211.ru


[Bug c/53656] sequence point bug

2012-06-14 Thread alexcheremkhin at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53656

--- Comment #2 from Alexey Cheremkhin  
2012-06-14 15:38:36 UTC ---
(In reply to comment #1)
> Looks similar to bug 48814.

Thank you very much.
It is definitely the same bug.
Bug 48814 was fixed on 2012-03-16, so I simply used the patch.

Alexey Cheremkhin; Compiler Department, KM211.
a...@km211.ru