public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/30935]  New: Wrong evaluation result
@ 2007-02-23 15:18 jrr at concept dot de
  2007-02-23 15:20 ` [Bug c/30935] " jrr at concept dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jrr at concept dot de @ 2007-02-23 15:18 UTC (permalink / raw)
  To: gcc-bugs

The following C program evaluates t.a to a *wrong* value of 5 instead of 9:

#include <stdio.h>

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/30935] Wrong evaluation result
  2007-02-23 15:18 [Bug c/30935] New: Wrong evaluation result jrr at concept dot de
@ 2007-02-23 15:20 ` jrr at concept dot de
  2007-02-23 15:22 ` jrr at concept dot de
  2007-02-23 15:36 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jrr at concept dot de @ 2007-02-23 15:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jrr at concept dot de  2007-02-23 15:19 -------
Created an attachment (id=13099)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13099&action=view)
Initial test case showing the bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30935


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/30935] Wrong evaluation result
  2007-02-23 15:18 [Bug c/30935] New: Wrong evaluation result jrr at concept dot de
  2007-02-23 15:20 ` [Bug c/30935] " jrr at concept dot de
@ 2007-02-23 15:22 ` jrr at concept dot de
  2007-02-23 15:36 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jrr at concept dot de @ 2007-02-23 15:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jrr at concept dot de  2007-02-23 15:22 -------
(In reply to comment #0)
> The machine is a Fedora Core 6 Linux x86_64 box.

Sorry, I meant "Fedora Core release 5 (Bordeaux)"


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30935


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/30935] Wrong evaluation result
  2007-02-23 15:18 [Bug c/30935] New: Wrong evaluation result jrr at concept dot de
  2007-02-23 15:20 ` [Bug c/30935] " jrr at concept dot de
  2007-02-23 15:22 ` jrr at concept dot de
@ 2007-02-23 15:36 ` rguenth at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-02-23 15:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2007-02-23 15:36 -------


*** This bug has been marked as a duplicate of 11751 ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30935


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-02-23 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-23 15:18 [Bug c/30935] New: Wrong evaluation result jrr at concept dot de
2007-02-23 15:20 ` [Bug c/30935] " jrr at concept dot de
2007-02-23 15:22 ` jrr at concept dot de
2007-02-23 15:36 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).