[LLVMdev] unique_ptr and llvm cast machinery

David Blaikie dblaikie at gmail.com
Mon Apr 14 21:47:07 PDT 2014


Anyone have opinions on whether the cast machinery should be taught to
handle unique_ptr?

Presumably that'd involve cast, etc, returning raw pointers when it
was passed references to unique_ptr, which might be
surprising/error-prone?

But the only errors would be:

1) double delete - if the result of the cast was used to take
ownership because the caller didn't realize there was a unique_ptr
that held ownership (eg: a function that returns a reference to a
unique_ptr, passed to cast, then ownership taken)

2) dangling pointers - but this wouldn't be more or less likely with
the change to cast.



More information about the llvm-dev mailing list