From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Ulrich Weigand" To: gcc@gcc.gnu.org Cc: "Hartmut Penner" Subject: ObjC bug on 64-bit architectures? Date: Mon, 15 Oct 2001 09:14:00 -0000 Message-id: X-SW-Source: 2001-10/msg00855.html Hello, I'm trying to track down an Objective C testsuite failure on 64-bit s390x. However, the problem doesn't appear to be s390x specific from what I can see; it looks to me like this bug should appear on every big-endian 64-bit platform with a 32-bit 'int' type. What happens is that the testcase (bycopy-3.m) crashes in main because a class_pointer of an objc_protocol is not correctly initialized. This is turn happens because the constructor __objc_init_protocols gets called with an incorrect struct objc_protocol_list having a count field of 0 (instead of 1), and hence does not initialize the protocol. The objc_protocol_list is generated by the objc frontend; the problem appears to be caused by a type mismatch. The definition of the structure objc_protocol_list says (from the file libobjc/objc/objc-api.h): struct objc_protocol_list { struct objc_protocol_list *next; int count; Protocol *list[1]; }; However, the compiler generates this instance: .align 8 .type _OBJC_CLASS_PROTOCOLS_MyObject,@object .size _OBJC_CLASS_PROTOCOLS_MyObject,24 _OBJC_CLASS_PROTOCOLS_MyObject: .quad 0 .quad 1 .quad _OBJC_PROTOCOL_MyProtocol The '.quad 1' is incorrect, because 'int' is a 32-bit data type; because our platform is big-endian, this causes the 'count' field to be read as 0. This assembly appears to be generated by the objc frontend routine generate_protocol_list (in the file gcc/objc/objc-act.c). Unfortunately, my understanding of frontend code is rather limited, but it looks like that routine is indeed doing a type cast from the integer constant that specifies the count to some pointer type. This looks like a bug to me, but I'm not sure how to fix it ... Could someone familiar with the objc frontend have a look at this? Thanks, Ulrich -- Dr. Ulrich Weigand Linux for S/390 Design & Development IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen Phone: +49-7031/16-3727 --- Email: Ulrich.Weigand@de.ibm.com