Bug 27233

Summary: incorrect xor result on arrays
Product: gcc Reporter: Raphael H Ribas <raphael.ribas>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Severity: normal CC: alexey, algorithmus, asokumar, av1474, bala, barnarr, behloul.younes, bmead15, buergel, carpman, chuchunxin, devnull, d_picco, eric.mcvicker, fuchsia.groan, gaurav_har, gcc-bugs, gcc, ggs, jandres, janis, jompo, krs, lid, lindahlb, lxg8906, mayer, mikaldaz, nakkore, nobs, pierre.van.de.laar_at_philips.com, qyang, ramiller, raoulgough, raphael.ribas, rglan, rjvbertin, robc, s9322036, SimonX200, smartmouse714, suan, super.aorta, svetozarmarkov, tczarnecki, vanveghel, vitaly, zshao
Priority: P3    
Version: 4.0.3   
Target Milestone: ---   
Host: x86 linux Target:
Build: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada, Known to work:
Known to fail: Last reconfirmed:

Description Raphael H Ribas 2006-04-21 00:38:40 UTC
the following code

#include <stdio.h>

int main() {
    int a[1],b[1];
    printf("%d %d\n",a[0],b[0]);
    return 0;

this should produce "7 5" as outpout but it produces "0 5"
Comment 1 Andrew Pinski 2006-04-21 00:40:19 UTC

That is undefined, you are modifing a[0] and b[0] more than once without a sequence point.

*** This bug has been marked as a duplicate of 11751 ***
Comment 2 Raphael H Ribas 2006-04-21 01:01:18 UTC
int main() {
    int a,b;
    printf("%d %d\n",a,b);
    return 0;

than why this one produces expected answer?
Comment 3 Andrew Pinski 2006-04-21 01:03:55 UTC
(In reply to comment #2)
> than why this one produces expected answer?

As I said it is undefined so it could produce your expected result or it does not have to.  But the example in comment #2 is also undefined for the same reason, it is just you get a different result but there is no one correct result here really.