[llvm-dev] LLVM 3.8 change in function argument lists?

Jonathan Roelofs via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 14 16:42:35 PDT 2016



On 3/14/16 5:38 PM, Dibyendu Majumdar via llvm-dev wrote:
> Hi,
>
> I am upgrading my project from 3.7 to 3.8. I find that following code
> used to compile in 3.7 but doesn't in 3.8 and I can't understand why.
>
> llvm::Function *mainFunc = ...;
> auto argiter = mainFunc->arg_begin();
> llvm::Value *arg1 = argiter++;
> arg1->setName("obj");
>
> But if I change the code to following it compiles:
>
> auto argiter = mainFunc->arg_begin();
> llvm::Value *arg1 = &(*argiter);
> arg1->setName("obj");
>
>
> As far as I can tell the first version should have worked as well. Any
> pointers to why the first version is now failing to compile?

 From the release notes:

"ilist_iterator<T> no longer has implicit conversions to and from T*, 
since ilist_iterator<T> may be pointing at the sentinel (which is 
usually not of type T at all). To convert from an iterator I to a 
pointer, use &*I; to convert from a pointer P to an iterator, use 
P->getIterator(). Alternatively, explicit conversions via 
static_cast<T>(U) are still available."

This was done to fix UB in the ilist implementation, IIRC.


Jon

>
> Thanks and Regards
> Dibyendu
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded


More information about the llvm-dev mailing list