From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dibyendu Majumdar Subject: Re: Sparse-LLVM issue compiling NULL pointers Date: Fri, 3 Mar 2017 03:01:12 +0000 Message-ID: References: <20170302052124.fsqogvysufayy4to@macbook.local> <20170302135655.s742zcslis5r56if@macpro.local> <20170302160403.zz5efgh34jvjh5q5@macpro.local> <20170302171842.xuk535w6wrfxke3b@macpro.local> <20170302200916.4agmd5jihtkzyvp5@macpro.local> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from mail-it0-f52.google.com ([209.85.214.52]:38107 "EHLO mail-it0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752447AbdCCQK0 (ORCPT ); Fri, 3 Mar 2017 11:10:26 -0500 Received: by mail-it0-f52.google.com with SMTP id m27so15808102iti.1 for ; Fri, 03 Mar 2017 08:10:25 -0800 (PST) In-Reply-To: Sender: linux-sparse-owner@vger.kernel.org List-Id: linux-sparse@vger.kernel.org To: Luc Van Oostenryck Cc: Linux-Sparse On 3 March 2017 at 02:52, Dibyendu Majumdar wrote: > Hi Luc, > > Next problem: > > The following fails. > > typedef unsigned long long size_t; > struct buffer_type_st { > struct buffer_type_st *next_buffer; > char *buffer; > }; > typedef struct buffer_type_st buffer_type_t; > struct link_st { > struct link_st *next; > }; > typedef struct link_st link_t; > struct allocator_st { > buffer_type_t *buffer_list; > link_t *free_list; > char *next_avail; > char *last; > size_t size; > size_t n; > }; > typedef struct allocator_st allocator; > extern void * > alloc_node(allocator * a); > extern void > grow_allocator(allocator * a); > void * > alloc_node(allocator * a) > { > link_t *tmp; > tmp = a->free_list; > return (void *) tmp; > } > > > I get LLVM assertion failure for following instruction: > > insn cast.64 %r4 <- (64) %r2 > > Assertion failed: isa(Val) && "cast() argument of incompatible > type!", file C:\d\llvm-3.9.0.src\include\llvm/Support/Casting.h, line > 237 > > I think this is because the linearize is outputting an integer cast > rather than pointer cast so LLVM is not happy. > Simpler example: void * alloc_node(void) { char *tmp; tmp = (void *)0; return tmp; }