From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27612 invoked by alias); 23 Feb 2007 15:18:13 -0000 Received: (qmail 27584 invoked by uid 48); 23 Feb 2007 15:18:01 -0000 Date: Fri, 23 Feb 2007 15:18:00 -0000 Subject: [Bug c/30935] New: Wrong evaluation result X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jrr at concept dot de" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-02/txt/msg02673.txt.bz2 The following C program evaluates t.a to a *wrong* value of 5 instead of 9: #include struct test { int a; }; int func(struct test* tp) { tp->a = 8; /* this update is lost */ return 1; } int main(int ac, char** av) { struct test t; t.a = 4; t.a += func(&t); /* t.a (=4) already loaded into a CPU register? */ printf("t.a=%d ", t.a); if (t.a == 9) { printf("OK\n"); return 0; } else { printf("BAD\n"); return 1; } } # gcc bad_eval.c && ./a.out t.a=5 BAD The machine is a Fedora Core 6 Linux x86_64 box. # uname -a Linux titan 2.6.16-1.2080_FC5 #1 SMP Tue Mar 28 03:38:47 EST 2006 x86_64 x86_64 x86_64 GNU/Linux # gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux Thread model: posix gcc version 4.1.0 20060304 (Red Hat 4.1.0-3) -- Summary: Wrong evaluation result Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jrr at concept dot de GCC build triplet: x86_64-redhat-linux GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30935