http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48814
Summary: Incorrect scalar increment result
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
The following test-case should output "2 3", but GCC outputs "1 2":
#include <stdio.h>
int arr[] = {1,2,3,4};
int count = 0;
int incr(){
return ++count;
}
int main(){
arr[count++]=incr();
printf("%d %d",count,arr[count]);
return 0;
}
(it may not be obvious; see
http://stackoverflow.com/questions/5827707/why-this-output/5828578#5828578 ).
Clang correctly handles this case.