------- Additional Comments From rth at gcc dot gnu dot org 2005-01-09 04:46
-------
Actually, I have a standards question here.
Assume for the purposes of discussion here that a source-level reference
variable
"X" is represented as a pointer variable "x" in the intermediate language. E.g.
int &A, &B, C; C = A + B;
lowers to
int *a, *b, C; C = *a + *b;
It appears that [expr.cond]/3 *does* preserve references. Thus it would
seem that the front end should lower
int &A, &B, &C; C = (A < B ? A : B);
to
int *a, *b, C; c = (*a < *b ? a : b);
and not
int *a, *b, *c; c = &(*a < *b ? *a : *b);
Note that comment #1 indicates that we're emitting the later.
If we'd actually written (*a < *b ? *a : *b) at the source level in C, it
would be illegal for us to take the address of the result, and so the
transformation to MAX_EXPR would be legitimate.
But I'm not sure what the actual rules for expressions for which references
are legitimate in C++. If it's legitimate to write
int A, &B, &C; C = (A < B ? A : B);
->
int A, *b, *c; c = &(A < *b ? A : *b);
then I think perhaps a more accurate representation would be
int A, *b, *c, *t; c = &*((A < *b ? t = &A : t = &*b), t);
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |mmitchel at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19199