[PATCH] D23466: ADT: Remove UB in ilist (and use a circular linked list)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 14 16:44:18 PDT 2016


> On Aug 14, 2016, at 4:42 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> 
>> On 2016-Aug-13, at 16:37, Mehdi Amini <mehdi.amini at apple.com <mailto:mehdi.amini at apple.com>> wrote:
>> 
>> 
>>> On Aug 13, 2016, at 2:54 PM, Duncan P. N. Exon Smith via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
>>> 
>>> 
>>>> On 2016-Aug-12, at 17:31, Duncan P. N. Exon Smith via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
>>>> 
>>>>> 
>>>>> ================
>>>>> Comment at: include/llvm/ADT/ilist.h:324
>>>>> @@ -424,7 +323,3 @@
>>>>> 
>>>>> -  iplist() : Head(this->provideInitialHead()) {}
>>>>> -  ~iplist() {
>>>>> -    if (!Head) return;
>>>>> -    clear();
>>>>> -    Traits::destroySentinel(getTail());
>>>>> -  }
>>>>> +  iplist() = default;
>>>>> +  ~iplist() { clear(); }
>>>>> ----------------
>>>>> Could be removed?
>>>> 
>>>> Certainly the destructor needs to stay.  I'll remove the default constructor if it still compiles (but I'm always wary about what will or will not compile on MSVC...)
>>> 
>>> BTW, this didn't compile without `iplist() = default`.
>> 
>> Interesting, what was the reason?
> 
> Specifically:
> 
> /Users/dexonsmith/data/llvm/working/include/llvm/ADT/ilist.h:599:3: error: constructor for 'llvm::ilist<llvm::yaml::Token>' must explicitly initialize the base class 'iplist<llvm::yaml::Token>' which does not have a default constructor
>   ilist() {}
>   ^
> /Users/dexonsmith/data/llvm/working/lib/Support/YAMLParser.cpp:751:10: note: in instantiation of member function 'llvm::ilist<llvm::yaml::Token>::ilist' requested here
> Scanner::Scanner(StringRef Input, SourceMgr &sm, bool ShowColors)
>          ^
> /Users/dexonsmith/data/llvm/working/include/llvm/ADT/ilist.h:284:7: note: 'llvm::iplist<llvm::yaml::Token, llvm::ilist_traits<llvm::yaml::Token> >' declared here
> class iplist : public Traits, ilist_node_access {
>       ^
> 1 error generated.
> 
> I assume this is because of:
> 
> iplist(const iplist &) = delete;

Makes sense, I missed this copy ctor deletion…

— 
Mehdi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160814/851181bb/attachment.html>


More information about the llvm-commits mailing list