== Quote from Walter Bright (newshou...@digitalmars.com)'s article > bearophile wrote: > > Bekenn: > > > >> The use of ref introduces a level of indirection. > > > > This is correct. But a minimally decent compiler must be able to remove this > > indirection where possible, like here, and produce efficient code. > Having the optimizer remove indirection is rarely possible in C or C++, due to > aliasing.
I'm sure there are tons of nitty-gritty details in implementing something like this properly, but **in principle**, can't the compiler put a runtime check in for aliasing and select the code path based on whether aliasing is present or not? Essentially, you'd have two generated functions, one that handles the aliasing case and one that handles the no-aliasing case.