|
From: | Wolfgang Lux |
Subject: | Re: problem with gnustep on OpenBSD sparc64 |
Date: | Thu, 7 Jul 2011 10:56:33 +0200 |
Sebastian Reitenbach wrote:
I extended the output a bit, to show the address used for size (a.k.a. context in parse_array)$ ./a.outsizeof_type: before calling parse_array: element_size: 0, size pointern: 0xfffffffffffcf260parse_array: type: [4i]], context a.k.a. size: 0xfffffffffffcf260sizeof_type: before calling parse_array: element_size: 0, size pointern: 0xfffffffffffcf0d0parse_array: type: i]], context a.k.a. size: 0xfffffffffffcf0d0 sizeof_type: sizeof(typeName): 4 size pointer: 0xfffffffffffcf0d0 sizeof_type: size: 32, size pointer: 0xfffffffffffcf0d0 parse_array: type: ]]sizeof_type: after calling parse_array: element_size: 0, element_count: 4, size pointern: 0xfffffffffffcf0d0 ^^^ as far as I can see, the value on address 0xfffffffffffcf0d0 should be 32, but I have no idea, why it is not 32???198 int element_size = 0;
^^^^^ The problem seems to be here ...
^ ^^^^^^^^^^^^^^ ... and here. The sizeof_type callback expects an argument with type size_t *, but &element_size has type int *. This does work on 32-bit architectures where sizeof(size_t) = sizeof(int) and it works coincidentally on low-endian 64-bit architectures like x86_64, but is definitely wrong for big-endian 64-bit machines like sparc.(gdb)200 fprintf(stderr, "sizeof_type: before calling parse_array: element_size: %i, size pointern: %p\n", element_size, &element_size);(gdb)sizeof_type: before calling parse_array: element_size: 0, size pointern: 0xfffffffffffe0340 201 int element_count = parse_array(&t, (type_parser)sizeof_type, &element_size);
In order to fix, change line 198 to size_t element_size = 0; Wolfgang
[Prev in Thread] | Current Thread | [Next in Thread] |