From: John S. <leg...@gm...> - 2008-12-28 04:53:47
|
Hi: Thanks, the workaround does work :) However, the problem is that I'm writing a CIL analysis for other people's code. It appears that any time I define and initialize a variable with the return value of a function, it introduces a temporary variable and splits in into 2 statements (as shown in my original post). I've tried this for pointers and for non-pointers. This behaviour contradicts the documentation for Cabs2cil.doCollapseCallCast, which states: "Without this option, CIL converts "T* x = malloc(n);" into "void* tmp = malloc(n); T* x = (T*)tmp;". If you don't need all casts to be made explicit, you can set Cabs2cil.doCollapseCallCast to true so that CIL won't insert a temporary and you can more easily determine the allocation type from calls to malloc" How can I fix this bug (please know that I'm not familiar with the CIL internals, so I would be extremely hesitant to modify it)? Cheers, legit 2008/12/27 Gabriel Kerneis <ke...@pp...> > On Thu, Dec 25, 2008 at 11:39:50AM -0500, John Smith wrote: > > int main (void) > > { > > a = returnConst(); > > int* p = foo(); > > > > return 0; > > } > > This is what I expected. I don't know if this is a bug or feature, but > anyway, > a workaround is to declare the pointer at the top of the main function. > > Hope this helps, > -- > Gabriel Kerneis > |