[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: AW: AW: [Tinycc-devel] Memory allocation and initialization ofarrays
From: |
Alexander Egorenkov |
Subject: |
AW: AW: AW: [Tinycc-devel] Memory allocation and initialization ofarrayswithdimension % 2 = 0 |
Date: |
Mon, 2 Feb 2009 16:58:10 +0100 |
How do i do it ?
-----Ursprüngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Joshua Phillips
Gesendet: Montag, 2. Februar 2009 16:51
An: address@hidden
Betreff: Re: AW: AW: [Tinycc-devel] Memory allocation and initialization
ofarrayswithdimension % 2 = 0
It is possible to flatten the commits into one, if nobody has fetched your new
commits yet.
On Monday 02 February 2009 14:55:43 Alexander Egorenkov wrote:
> OK, i checked in my changes into mob branch.
> Sorry, i did actually 2 commits because i am a GIT newby :-)
>
> Alex.
>
> Regards.
>
> -----Ursprüngliche Nachricht-----
> Von: address@hidden
> [mailto:address@hidden
> Im Auftrag von grischka Gesendet: Montag, 2. Februar 2009 15:03
> An: address@hidden
> Betreff: Re: AW: [Tinycc-devel] Memory allocation and initialization
> of arrayswithdimension % 2 = 0
>
> Alexander Egorenkov wrote:
> > Here is the correct patch.
>
> Thanks.
>
> If you happen to have GIT around please feel free to push your patch
> on our "mob" branch:
>
> git push ssh://address@hidden/srv/git/tinycc.git mypatch:mob
>
> --- grischka
>
> > -------------------------------------------------------------------------
> >-- --- tcc.c.old Mon Feb 2 11:18:15 2009
> > +++ tcc.c.new Mon Feb 2 11:22:31 2009
> > @@ -6130,8 +6130,15 @@
> > return s->c;
> > } else if (bt == VT_PTR) {
> > if (type->t & VT_ARRAY) {
> > + int ts;
> > +
> > s = type->ref;
> > - return type_size(&s->type, a) * s->c;
> > + ts = type_size(&s->type, a);
> > +
> > + if (ts < 0 && s->c < 0)
> > + ts = -ts;
> > +
> > + return ts * s->c;
> > } else {
> > *a = PTR_SIZE;
> > return PTR_SIZE;
> > --------------------------------------------------------------------
> > --
> > -------
> >
> > Alex.
> >
> > Regards.
> >
> > -----Ursprüngliche Nachricht-----
> > Von: address@hidden
> > [mailto:address@hidden
> > g]
> > Im Auftrag von Alexander Egorenkov
> > Gesendet: Montag, 2. Februar 2009 12:21
> > An: address@hidden
> > Betreff: [Tinycc-devel] Memory allocation and initialization of
> > arrays withdimension % 2 = 0
> >
> >
> > Hi TCC developers,
> >
> > i think, found a bug with memory allocation and initialization of
> > arrays with dimensions 2, 4, 6 etc.
> >
> > Example (x86, linux, tinycc 0.9.24):
> > ----------------------------------------------------
> > #include <stdio.h>
> >
> > int main(int argc, char **argv)
> > {
> > int a[] = { 1, 2, 3, 4 };
> > int b[][] = { { 5, 6 }, { 7 , 8 } };
> >
> > printf("%d %d %d %d\n", a[0], a[1], a[2], a[3]);
> >
> > return 0;
> > }
> >
> > ----------------------------------------------------
> >
> > Output:
> > ----------------------------------------------------
> > 5 6 7 4
> > ----------------------------------------------------
> >
> > The problem is in the function tcc.c:type_size.
> >
> >
> > I could solve the problem by appling the following patch:
> > ----------------------------------------------------
> > --- tcc.c.old Mon Feb 2 11:18:15 2009
> > +++ tcc.c.new Mon Feb 2 11:19:00 2009
> > @@ -6130,8 +6130,15 @@
> > return s->c;
> > } else if (bt == VT_PTR) {
> > if (type->t & VT_ARRAY) {
> > + int ts;
> > +
> > s = type->ref;
> > - return type_size(&s->type, a) * s->c;
> > + ts = type_size(&s->type, a) * s->c;
> > +
> > + if (ts < 0 && s->c < 0)
> > + ts = -ts;
> > +
> > + return ts * s->c;
> > } else {
> > *a = PTR_SIZE;
> > return PTR_SIZE;
> > ----------------------------------------------------
> >
> > Alex.
> >
> > Regards.
> >
> >
> >
> >
> > _______________________________________________
> > Tinycc-devel mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/tinycc-devel
> >
> >
> > _______________________________________________
> > Tinycc-devel mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/tinycc-devel