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

Partially implemented or broken C extension ?


Hello all,

I have a question about GNU C extension that permits the use
of `?:' in lvalues. Consider the following program:

main () {
  int a = 1, b = 2, c = 3;
  (a ? a : b) = c;
}

It compiles and works fine. But

main () {
  int a = 1, b = 2, c = 3;
  ((a > b) ? a : b) = c;
}

doesn't compile (`invalid lvalue in assignment'). But the following
text is taken from GNU C Info documentation (Generalized Lvalues):

   "A conditional expression is a valid lvalue if its type is not void
and the true and false branches are both valid lvalues.  For example,
these two expressions are equivalent:
     (a ? b : c) = 5
     (a ? b = 5 : (c = 5))"

In a second program above, all these conditions seems kept. Is this
my mistake (if yes, where ?) or something wrong with GCC ? My GCC
version is 2.95.2.

Thanks,
Dmitry Antipov <dmitry.antipov@auriga.ru>.
Please e-mail me directly if possible.



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