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++ PATCH] Don't allow taking the address of an rvalue reference (PR c++/35153)


Doug Gregor wrote:

So, I think your check should go in build_unary_op -- unless for some
reason it can't, like if there's a compiler-generated need to take the
address of the rvalue reference,

Bingo. This is exactly what happened---compiler-generated code was going through build_unary_op, and triggering this error when it was okay to take the address of the result.

OK.


and we're going through build_unary_op
instead of build_address.

I didn't think of that. build_address doesn't do the ADDR_EXPR/INDIRECT_REF simplification, which some of the current callers of build_unary_op(ADDR_EXPR...) might rely on. So, I can try to change the compiler-generated calls to build_unary_op(ADDR_EXPR...) into build_address, and move the address-of-rvalue check into build_unary_op, if you'd still prefer that implementation.

Yes, I think that's the Right Answer. If anything in the front end depends on that simplification for compiler-generated code, it seems busted on its face to me -- and one certainly hopes that the middle-end is plenty smart enough to work this out these days.


In general, the front end is going to be simpler and more reliable if we clearly differentiate between compiler-generated implicit stuff (the sort of thing that would be generated during IL lowering) and user-level stuff.

Thanks,

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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