This is the mail archive of the
mailing list for the GCC project.
Re: [C++] PR19531 NRV is performed on volatile temporary
sorry I was looking at ISO/IEC 14882 (first edition). In 14882:2003 this
is indeed restricted to non-volatile automatic object. please ignore
this comment. thx
Indeed, I reread the parts on volatile and object copying, the standard
states nrv is allowed if the cv-unqualified types match, so strictly
volatile A a;
and the function
have the same cv-unqualified type...
so this volatile optimization is surprisingly correct !
Nevertheless, it would have been useful to have a way to force a call to
the copy constructor... but the standard allows this optimisation here,
Unless there is a consensus that this optimisation could be avoided on
volatile objects for convenience, this is not a bug and I will update