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



Mark Mitchell wrote: << snap>>

Is the check for volatility on both the return type of the function --
TREE_TYPE (TREE_TYPE (fndecl)) -- and on the RESULT_DECL -- TREE_TYPE
(r)) -- necessary?

I would expect that checking the volatility of the function return type
is sufficient; that's the language issue.  If, for whatever reason, the
compiler were to make the RESULT_DECL volatile, for a function with a
non-volatile return, I believe that the NRV would still be valid.

Would you please test removing the check on the RESULT_DECL from your patch?


it is the other way: with the nrv8.C (attached in the patch) test, only the check on the RESULT_DECL is necessary, testing the volatility of the *volatile A l;* object. Without it the check doesn't pass.
I think this is what 12.8 15 was originally about, before Core DR20 extended it to the function's return type.


I also though that there would be a language issue with the volatility of the function's return type, but the volatility flag is not set on the return type of the cpctor. Should it be ? I'm not sure since with:
A (volatile const A & o) { d = o.d + 2; }
the cpctor return type is not volatile, only the temporary object is, but I'd prefer to let that to the experts's hands.


So I conservatively added the check on the function's return type to match core dr20 extension (quoted in the bugzilla entry but I don't have it) although I was not able to make up a test case.

Best Regards
Christian


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