3 ms·
I'd expect the compiler to allocate space for ErrorOr on the stack of the caller and pass an address to this space in a hidden parameter. In effect, the impleme
by barrkel 10y ago
I'd expect the compiler to allocate space for ErrorOr on the stack of the caller and pass an address to this space in a hidden parameter. In effect, the implementation func0 would probably be typed a bit like this:
void func0(llvm::ErrorOr<int> *__result)
An advantage of passing a pointer to the error that you may be missing is that if you can pass this location all the way down, you can eliminate redundant copies / moves / assignments. This is harder when the return value and error value are combined in a single tagged union, so there will be a lot more data shuffling code all the way back up the stack.