https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109945
--- Comment #26 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #25) > However, [class.temporary] p3 explicitly allows the compiler to create a > temporary object when returning a class with a trivial copy constructor and > trivial (or deleted) destructor. This is permitted precisely to allow what > the x86_64 ABI requires: the return value is passed in registers. Completely > eliding the creation and copy of a temporary would have required an ABI > break. N.B. this permission to create an intermediate temporary only depends on the class type and whether it has a trivial copy constructor etc. *not* on the actual platform ABI and whether it _actually_ gets passed in registers or not. So GCC is always allowed to make a temporary copy even on i686 where the object is really passed in memory via invisible reference, because the class has a trivial copy ctor. The fact that it doesn't actually make that copy on i686 doesn't make the program valid on i686 IMHO. Conceptually, there's a temporary which is copied then goes out of scope, and the 'global' pointer becomes invalid and cannot be dereferenced. The fact that the actual copy isn't present any more in the codegen (and the pointer happens to point to w itself which now exists at the same address as the temporary previously existed) doesn't make the program valid.