re PR libobjc/23108 (alignment bug in libobjc/archive.c)

2005-09-04  Andrew Pinski  <pinskia@physics.uc.edu>
            Rasmus Hahn  <rassahah@neofonie.de>

        PR libobjc/23108
        * objc.dg/type-stream-1.m: New test.

2005-09-04  Andrew Pinski  <pinskia@physics.uc.edu>
            Rasmus Hahn  <rassahah@neofonie.de>

        PR libobjc/23108
        * archive.c (objc_write_type): Correct the element offset.
        (objc_read_type): Likewise.

Co-Authored-By: Rasmus Hahn <rassahah@neofonie.de>

From-SVN: r103832
This commit is contained in:
Andrew Pinski 2005-09-04 17:05:39 +00:00 committed by Andrew Pinski
parent 1c9ef36d01
commit ca59f04b87
4 changed files with 40 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2005-09-04 Andrew Pinski <pinskia@physics.uc.edu>
Rasmus Hahn <rassahah@neofonie.de>
PR libobjc/23108
* objc.dg/type-stream-1.m: New test.
2005-09-04 Tobias Schl"uter <tobias.shclueter@physik.uni-muenchen.de>
PR fortran/23661

View file

@ -0,0 +1,25 @@
/* { dg-options "-fgnu-runtime" } */
/* { dg-do run } */
#include <objc/typedstream.h>
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
FILE *f; TypedStream *ts;
struct T { int a, b; } x = { 1, 2 };
f = fopen ("foo", "w"); ts = objc_open_typed_stream (f, OBJC_WRITEONLY);
objc_write_type (ts, @encode(struct T), &x);
objc_close_typed_stream (ts); fclose (f);
f = fopen ("foo", "r"); ts = objc_open_typed_stream (f, OBJC_READONLY);
struct T y;
objc_read_type (ts, @encode(struct T), &y);
if (y.a != 1)
abort ();
if (y.b != 2)
abort ();
objc_close_typed_stream (ts); fclose (f);
remove ("foo");
return 0;
}

View file

@ -1,3 +1,10 @@
2005-09-04 Andrew Pinski <pinskia@physics.uc.edu>
Rasmus Hahn <rassahah@neofonie.de>
PR libobjc/23108
* archive.c (objc_write_type): Correct the element offset.
(objc_read_type): Likewise.
2005-08-17 Kelley Cook <kcook@gcc.gnu.org>
* All files: Update FSF address.

View file

@ -1069,7 +1069,7 @@ objc_write_type (TypedStream *stream, const char *type, const void *data)
while (*type != _C_STRUCT_E)
{
align = objc_alignof_type (type); /* padd to alignment */
acc_size += ROUND (acc_size, align);
acc_size = ROUND (acc_size, align);
objc_write_type (stream, type, ((char *) data) + acc_size);
acc_size += objc_sizeof_type (type); /* add component size */
type = objc_skip_typespec (type); /* skip component */
@ -1165,7 +1165,7 @@ objc_read_type(TypedStream *stream, const char *type, void *data)
while (*type != _C_STRUCT_E)
{
align = objc_alignof_type (type); /* padd to alignment */
acc_size += ROUND (acc_size, align);
acc_size = ROUND (acc_size, align);
objc_read_type (stream, type, ((char*)data)+acc_size);
acc_size += objc_sizeof_type (type); /* add component size */
type = objc_skip_typespec (type); /* skip component */