This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37146] [4.4 Regression] Invalid types with COND_EXPR
- From: "dodji at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Sep 2008 07:56:17 -0000
- Subject: [Bug c++/37146] [4.4 Regression] Invalid types with COND_EXPR
- References: <bug-37146-12710@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from dodji at gcc dot gnu dot org 2008-09-11 07:56 -------
@Jakub:
* I think (x ? c.i : c.j) = y; should be valid. because we then fall into the
item 4 of the spec, PDF page 115, section 5.16: Conditional operator which
reads:
"If the second and third operands are lvalues and have the same type, the
result is of that type and is an lvalue"
* (x ? c.i : a) = y; should not be valid because we fall into the item 5 that
says:
"Otherwise, the result is an rvalue".
Then we fall into item 6:
"Lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3)
standard conversions are performed on the second and third operands. After
those conversions, one of the following shall hold:
? The second and third operands have the same type; the result is of that
type.
"
So after this point, the result is an rvalue. So the assignation becomes
invalid.
* (x ? c.i : c.k) = y; Should be invalid as well.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37146