[cfe-dev] Trouble with MSVC again

Olaf Krzikalla Olaf.Krzikalla at tu-dresden.de
Mon May 10 08:09:16 PDT 2010


Hi @clang,

just now I stumbled over a MSVC issue which I first considered being a 
reincarnation of a bug we've discussed here about a year ago (Jun/26/2009).
The troublesome lines are in Action.h:127

    FullExprArg &operator=(const FullExprArg& Other) {
      Expr = ExprArg(move(const_cast<FullExprArg&>(Other).Expr));
      return *this;
    }


(Doug should know them from last weekend.)
However after digging somewhat deeper I'm rather puzzled. Apparently 
DISABLE_SMART_POINTERS is not defined on my system. However, then 
ExprArg is an ASTOwningResult and the move result gets constructed to an 
ASTOwningResult. The strange part: the operator= of ASTOwningResult is 
really private, so MSVC is blatantly right by complaining.
I thought removing the "ExprArg" cast would help, but if you look at 
Ownership.h:797 then you'll notice that move returns not an 
ASTResultMover but an ASTOwningResult. Thats even more strange. Am I the 
only one with !defined(DISABLE_SMART_POINTERS) == true? (I made the last 
update about two weeks ago and it worked fine then). Or is there 
something broken in my build configuration and DISABLE_SMART_POINTERS 
should be defined? In any case I can't imagine how any compiler can 
build clang without a defined DISABLE_SMART_POINTERS.
Any ideas?

Best regards
Olaf Krzikalla


PS: my solution is as follows:

template <ASTDestroyer Destroyer> inline
moving::ASTResultMover<Destroyer> hack_move(ASTOwningResult<Destroyer> 
&ptr) {
  return moving::ASTResultMover<Destroyer>(ptr);
}

and

FullExprArg &operator=(const FullExprArg& Other) {
   Expr = hack_move(const_cast<FullExprArg&>(Other).Expr);
   return *this;
}


I have the sneaking suspicion that hack_move actually is the correct 
move implementation.





More information about the cfe-dev mailing list