This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PR c++/20280] hoist indirect_ref out of addressable cond_exprs
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, gcc-bugzilla at gcc dot gnu dot org
- Date: Thu, 03 Mar 2005 17:35:58 -0800
- Subject: Re: [PR c++/20280] hoist indirect_ref out of addressable cond_exprs
- Organization: CodeSourcery, LLC
- References: <oroee1xj5d.fsf@livre.redhat.lsd.ic.unicamp.br>
Alexandre Oliva wrote:
\
I went ahead and verified that I didn't break bit-field lvalues in
conditional expressions (my first attempt did), but I was surprised to
find out that the calls to h() pass. I understand why they do (we
create a temporary and bind to that), but I'm not sure this is correct
behavior. Opinions?
+ // Hmm... I don't think these should be accepted. The conditional
+ // expressions are lvalues for sure, and 8.5.3/5 exempts lvalues
+ // that are bit-fields, but not lvalues that are conditional
+ // expressions involving bit-fields.
+ h (b ? x.i : x.j);
+ h (b ? x.i : x.k);
+ h (b ? x.j : x.k);
That's legal because "h" takes a "const &", which permits the compiler
to create a temporary. If it takes a non-const reference, you should
get an error.
And, I think these kinds of transformations (if necessary) should be
done in a langhook during gimplification, not at COND_EXPR-creation
time. We really want the C++ front-end's data structures to be an
accurate mirror of the input program for as long as possible.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304