From 9a61d2962aed5eccd288d1b78f0f2402b2b2096d Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 12 Jun 2008 16:41:41 +0200 Subject: [PATCH] resolved strict aliasing problem by changing type cast --- Cython/Compiler/ModuleNode.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 40e31ca9..1bc6f3fe 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -821,10 +821,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): #if need_self_cast: # self.generate_self_cast(scope, code) if type.vtabslot_cname: - code.putln("*(struct %s **)&p->%s = %s;" % ( - type.vtabstruct_cname, + if base_type: + struct_type_cast = "(struct %s*)" % base_type.vtabstruct_cname + else: + struct_type_cast = "" + code.putln("p->%s = %s%s;" % ( type.vtabslot_cname, - type.vtabptr_cname)) + struct_type_cast, type.vtabptr_cname)) for entry in py_attrs: if entry.name == "__weakref__": code.putln("p->%s = 0;" % entry.cname) -- 2.26.2