Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: lvalues from the ternary op Date: Wed, 04 Jan 2017 13:48:54 -0800 Organization: None to speak of Lines: 27 Message-ID: References: <8737kned1h.fsf@bsb.me.uk> <8737klapvv.fsf@bsb.me.uk> <877f6alefh.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="167f7d05f22907ea8e3985ed50c4ed73"; logging-data="28834"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19o4vKLEqmT/qQyi+7kmPub" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:IKvfbPp53+JNr5XbGiYWWMpY1GE= sha1:3D3DYT7MtyC0uG9pte9N5W2UiKU= Xref: csiph.com comp.lang.c:101136 Ben Bacarisse writes: [...] > But I don't think that gets us any closer to knowing what might or might > not be "reasonable" in C. The C standard enumerates all the expression > forms that are lvalues and, as in the case of x.y for example, it > sometimes depends on whether one or other part of the expression is > itself an lvalue. So there's no obvious reason that it could not say > that a conditional expression is an lvalue if both arms are lvalue > expressions. And of the same type, or perhaps compatible types would be sufficient. For example, this: int x; double y; (condition ? x : y) = 42; would be difficult to implement sensibly. Taking the address of a ternary expression would be even more difficult. (C++ already does this; I haven't checked the standard's wording.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"