Dibyendu Majumdar via llvm-dev
2016-Mar-14 23:38 UTC
[llvm-dev] LLVM 3.8 change in function argument lists?
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? Thanks and Regards Dibyendu
David Blaikie via llvm-dev
2016-Mar-14 23:41 UTC
[llvm-dev] LLVM 3.8 change in function argument lists?
Duncan - I assume this is your ilist work? Dibyendu: Iterators are not necessarily pointers, so you can't always expect to convert an iterator straight to a pointer to the element type in general. On Mon, Mar 14, 2016 at 4:38 PM, Dibyendu Majumdar via llvm-dev < llvm-dev at lists.llvm.org> 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? > > Thanks and Regards > Dibyendu > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <lists.llvm.org/pipermail/llvm-dev/attachments/20160314/d030794b/attachment.html>
Jonathan Roelofs via llvm-dev
2016-Mar-14 23:42 UTC
[llvm-dev] LLVM 3.8 change in function argument lists?
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 > lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Jon Roelofs jonathan at codesourcery.com CodeSourcery / Mentor Embedded
Dibyendu Majumdar via llvm-dev
2016-Mar-14 23:48 UTC
[llvm-dev] LLVM 3.8 change in function argument lists?
On 14 March 2016 at 23:42, Jonathan Roelofs <jonathan at codesourcery.com> wrote:>> 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"); >> >> > 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. >Ok thanks. Regards Dibyendu
Duncan P. N. Exon Smith via llvm-dev
2016-Mar-15 00:05 UTC
[llvm-dev] LLVM 3.8 change in function argument lists?
> On 2016-Mar-14, at 16:41, David Blaikie <dblaikie at gmail.com> wrote: > > Duncan - I assume this is your ilist work?Yes. Looks like the rest has been answered by others!> Dibyendu: Iterators are not necessarily pointers, so you can't always expect to convert an iterator straight to a pointer to the element type in general. > > On Mon, Mar 14, 2016 at 4:38 PM, Dibyendu Majumdar via llvm-dev <llvm-dev at lists.llvm.org> 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? > > Thanks and Regards > Dibyendu > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >