This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

Christian

Indeed, I reread the parts on volatile and object copying, the standard states nrv is allowed if the cv-unqualified types match, so strictly speaking
the object
volatile A a;
and the function
A bar()
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, that's it.

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 PR19531 accordingly.

Best Regards

Christian










Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]