public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/43456]  New: gcc -O code generation error
@ 2010-03-20 20:30 gccbug at dworkin dot nl
  2010-03-20 20:40 ` [Bug c/43456] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: gccbug at dworkin dot nl @ 2010-03-20 20:30 UTC (permalink / raw)
  To: gcc-bugs

gcc configuration:

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-3ubuntu3'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-3ubuntu3) 

The bug occurs with all gcc 4.x versions I tried (4.0.1 on OS X, 4.2.1 on OS X,
4.3.3 on OpenSolaris,
4.4.1 on Ubuntu 9.10) but NOT with gcc 3.4.3 on Solaris 10. I have reproduced
it on i386 and PPC platforms.

To reproduce, compile the code below.  The bug occurs in generating the code
for foo(). Without -O, the begin and end values are identical; with -O, they
are not.  I'm sorry if the code is a bit hard to read, it was compiled to C
from a different language.

Regards,
Felix Croes


# include <stdio.h>

typedef int Int;
typedef unsigned int Uint;

typedef char bool;
typedef struct _string_ string;
typedef struct _array_ array;
typedef struct _object_ object;
typedef struct _value_ value;
typedef struct _control_ control;
typedef struct _dataplane_ dataplane;
typedef struct _dataspace_ dataspace;
typedef struct _frame_ frame;
typedef unsigned short uindex;
typedef uindex sector;
typedef unsigned short ssizet;
typedef char eindex;

typedef struct _rlinfo_ {
    Int maxdepth;
    Int ticks;
    bool nodepth;
    bool noticks;
    struct _rlinfo_ *next;
} rlinfo;
struct _frame_ {
    frame *prev;
    uindex oindex;
    array *lwobj;
    control *ctrl;
    dataspace *data;
    control *p_ctrl;
    unsigned short p_index;
    unsigned short nargs;
    bool external;
    bool sos;
    uindex foffset;
    struct _dfuncdef_ *func;
    char *prog;
    char *pc;
    value *stack;
    value *sp;
    value *lip;
    value *argp;
    value *fp;
    Int depth;
    rlinfo *rlim;
    Int level;
    bool atomic;
};
struct _value_ {
    char type;
    bool modified;
    uindex oindex;
    union {
 Int number;
 Uint objcnt;
 string *string;
 array *array;
 value *lval;
    } u;
};

extern void i_push_value (frame*, value*);
extern void i_index (frame*);
extern void i_funcall (frame*, object*, array*, int, int, int);

void foo(f)
register frame *f;
{
register Int ivar3 = 0;
register Int ivar10 = 1;
register Int ivar11 = 2;

(ivar11 |= (((i_push_value(f, (f->fp - 1)),
(--f->sp)->type = 0x01, f->sp->u.number = ((Int) 0x1L), i_index(f),
(--f->sp)->type = 0x01, f->sp->u.number = ((Int) 0x8L), kf_and(f),
(f->sp++)->u.number) ? ((Int) 0x1L) : ((Int) 0x0L)) | (((--f->sp)->type = 0x01,
f->sp->u.number = ivar10,
(f->argp + 3)->u.number = ivar3,
i_funcall(f, (object *) ((void *)0), (array *) ((void *)0), 0, 5 , 1),
(f->sp++)->u.number) ? ((Int) 0x4L) : ((Int) 0x0L))));
}

void i_push_value(f, v)
frame *f;
value *v;
{
    --f->sp;
}

void i_index(f)
frame *f;
{
    f->sp++;
}

int kf_and(f)
frame *f;
{
    f->sp++;
}

void i_funcall(f, obj, arr, a, b, c)
frame *f;
object *obj;
array *arr;
int a, b, c;
{
}

main()
{
    frame f;
    value stack[100];

    f.sp = f.argp = stack + 50;
    printf("begin %08x\n", f.sp);
    foo(&f);
    printf("end %08x\n", f.sp);
}


-- 
           Summary: gcc -O code generation error
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gccbug at dworkin dot nl
 GCC build triplet: Linux ubuntu 2.6.32-16-generic #25-Ubuntu SMP Tue Mar 9
                    16:33:52
  GCC host triplet: Linux ubuntu 2.6.32-16-generic #25-Ubuntu SMP Tue Mar 9
                    16:33:52
GCC target triplet: Linux ubuntu 2.6.32-16-generic #25-Ubuntu SMP Tue Mar 9
                    16:33:52


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


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

end of thread, other threads:[~2010-03-20 23:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-20 20:30 [Bug c/43456] New: gcc -O code generation error gccbug at dworkin dot nl
2010-03-20 20:40 ` [Bug c/43456] " pinskia at gcc dot gnu dot org
2010-03-20 20:53 ` rguenth at gcc dot gnu dot org
2010-03-20 20:59 ` pinskia at gcc dot gnu dot org
2010-03-20 21:01 ` rguenth at gcc dot gnu dot org
2010-03-20 21:17 ` pinskia at gcc dot gnu dot org
2010-03-20 21:18 ` pinskia at gcc dot gnu dot org
2010-03-20 21:51 ` gccbug at dworkin dot nl
2010-03-20 21:54 ` pinskia at gcc dot gnu dot org
2010-03-20 23:14 ` gccbug at dworkin dot nl
2010-03-20 23:19 ` pinskia at gcc dot gnu dot org
2010-03-20 23:46 ` joseph at codesourcery dot com

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).