This is the mail archive of the gcc-bugs@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]

[Bug c++/7503] (x < Y ? X : Y) as an lvalue and assignment


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7503



------- Additional Comments From moore_mn at cobra dot cs dot mercer dot edu  2003-08-19 08:23 -------
Subject:  (x < Y ? X : Y) as an lvalue and assignment

I believe that C allows it too.
I also believe that C99 allows all of
the short-cut versions ( ?> and friends).

I might have made an attempt to fix it
myself (in g++) if it could easily be converted
to an equivalent if/else stmt, but that gets
complex and I don't know the internals well
enough.  Converting it to evaluate to a
reference to the "winner" would break
for register variables.  Always converting
(with or without the assignment) would
break if there were a constant as one of
the contestants (contestants meaning possible
results of the ?: ).
I think that ?: and friends are almost more
trouble than they are worth, with conditional
exacution and conditional assignments.
What still bothers me is that the second
test program I sent works(or did when I sent it),
while the first didn't.  The only real difference
was that the result of the operation in the version
that didn't work could be determined at compile
time while the other asks for input which is used
to determine the outcome.
It probably should be disabled and an error issued
because there may be some code somewhere out there
that uses this and expects it to work, since it
compiles without a hitch.  Well, either people
are assuming that it works (and their code behaves
badly, but not such that they notice) or they are
not using it.  Either way, an error should be reported
if it might be broken.  (my guess, no one is using it
except for CS students and professors, and then in
test code to see if it works)

Nathan Moore


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