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 15:21:46 -0800 Organization: None to speak of Lines: 29 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="823e57597edb8da97e8f43b1b8c9fed4"; logging-data="28834"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qCp/aA+0AbFDsN33mNBQs" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:447Blvaz7ASwXow/xvrx/E44PaA= sha1:X0UP44LiPF73XOFJClqIqzZHWhc= Xref: csiph.com comp.lang.c:101146 supercat@casperkitty.com writes: > On Wednesday, January 4, 2017 at 3:48:34 PM UTC-6, Keith Thompson wrote: >> 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.) > > The Standard already includes type resolution rules for condition?p:q where > p and q are pointers. If the result of the conditional expression is used > as an object, is there any reason the type resolution rules for > *(condition ? &x : &y) couldn't be used for (condition ? x : y), but with > the proviso that if the address of the expression isn't taken, x and y need > not be regarded as having had their addresses taken by the expression, would > not be adequate? No reason I can think of (but I'd probably phrase the proviso differently). Of course (condition ? x : y) in the example above still wouldn't be an lvalue. -- 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"