https://issues.dlang.org/show_bug.cgi?id=20752
kinke <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from kinke <[email protected]> --- (In reply to Iain Buclaw from comment #1) > For finding out if a struct is to be returned using (N)RVO, the right test > to use would be __traits(isPOD). > > If a struct is non-POD, then it should _always_ be passed around by > invisible reference, no ifs, no buts, no excuses. > > However, that's ignoring static arrays, which is a little more hairy to find > out, as they need to be big enough to be considered returning in memory. > But just what is "big enough" is a very target-specific question. That goes for large structs too, not just static arrays, so isPOD is definitely not sufficient. The isReturnOnStack trait isn't directly related to NRVO and only depends on the ABI; in LLVM lingo, passing a pointer to the pre-allocated result is called sret, struct-return. NRVO just means that a named variable in the callee will be emplaced into that memory directly, so an sret ABI requirement for the callee is an orthogonal prerequisite for NRVO to work (in the callee). --
