[C++] PR19531 NRV is performed on volatile temporary

Christian BRUEL christian.bruel@st.com
Tue Oct 30 15:26:00 GMT 2007


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
> 
> 
> 
> 
> 
> 
> 
> 



More information about the Gcc-patches mailing list