This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/8030: strange behaviour of side effect operator


>Number:         8030
>Category:       c
>Synopsis:       strange behaviour of side effect operator
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 25 02:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     achille.fouilleul@gambro.com
>Release:        gcc-2.95
>Organization:
>Environment:
both Linux and Cygwin
>Description:
Let's consider the following code:

int main() {
	int a = 1;
	int b;

	b = a++ + a;
	printf("%i\n", b);
	return 0;
}

this prints "2" with GCC, whereas it prints "3" with CodeWarrior and Lcc.
Hint: I saw that in the assembler output the incrementation statement occurs AFTER the addition one.
>How-To-Repeat:
Just compile it! "gcc bug.c -o bug"
>Fix:
Dunno. Not a gcc expert!
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]