[LLVMdev] MS VS2010 std implementation: "Cannot assign iterators to two different blocks!"

Bob Floyd bobfloyd at comcast.net
Wed Oct 20 08:20:29 PDT 2010


Duncan,

As I am both an LLVM user and new to it I do not check in any changes, so I
have not made a fix.

However, to make LLVM work under VS2010 in my environment I replaced the
assignment constructor with the following
which fixes the issue on the simple tests in my environment which I have
tried. Any developer can validate this and check it in, although this fix
deletes the assert check and is not particularly pretty to my taste.

Bob

In CFG.h, replace the assignment constructor with:

////////////////////////////////////////////////////////////////////////////
//////////
  inline const _Self &operator=(const _Self &I) {
    this->~SuccIterator();
    new (this) _Self(I);
    // VS2010 std implements deque (on which stack is built) copy
constructor
    // as reserving the right to swap elements. The swap method uses
`operator=`
    // as follows:
    // template<class _Ty> inline
    //    void swap(_Ty& _Left, _Ty& _Right)
    //	  {	// exchange values stored at _Left and _Right
    //	    _Ty _Tmp = _Move(_Left);
    //	    _Left  = _Move(_Right);   <<<<<<<<< calls this `operator=`
    //	    _Right = _Move(_Tmp);
    //	  }
    // However, `_Self`, does not implement a full assignment operator
    // in favor of defense against misuse.
#ifdef PROBLEM    
    assert(Term == I.Term &&"Cannot assign iterators to two different
blocks!");
    idx = I.idx;
#endif // PROBLEM    
    return *this;
  }
////////////////////////////////////////////////////////////////////////////
/////////////

-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On
Behalf Of Duncan Sands
Sent: Wednesday, October 20, 2010 5:00 AM
To: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] MS VS2010 std implementation: "Cannot assign
iterators to two different blocks!"

Hi Bob, was this issue resolved?

Ciao,

Duncan.

> When using MS VS2010 there is an issue with std:
>
> `SuccIterator` implements a partial assignment operator:
>
> inline const _Self &operator=(const _Self &I) {
>
> assert(Term == I.Term &&"Cannot assign iterators to two different
blocks!");
>
> idx = I.idx;
>
> return *this;
>
> }
>
> For copy construction, MS VS2010 std reserves the right, and sometimes
calls,
>
> a method to reverse elements which does so by swap:
>
> template<class _Ty> inline
>
> void swap(_Ty& _Left, _Ty& _Right)
>
> { // exchange values stored at _Left and _Right
>
> _Ty _Tmp = _Move(_Left);
>
> _Left = _Move(_Right); <<<<<<<<<<<<< Needs FULL assignment operator!!!!
>
> _Right = _Move(_Tmp);
>
> }
>
> When `_Ty` is `SuccIterator const` the assert "Cannot assign iterators to
two
> different blocks!" can fail.
>
> Can this be a workaround:
>
> inline const _Self &operator=(const _Self &I) {
>
> new (this) _Self(I);
>
> return *this;
>
> }
>
> The larger question is can both the assert be preserved and swap
satisfied?
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list