Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Meaning of "expression" Date: Fri, 28 Aug 2026 17:23:20 -0700 Organization: A noiseless patient Spider Lines: 69 Message-ID: <86y0dpwz9j.fsf@linuxsc.com> References: <10v7b32$2u85v$1@dont-email.me> <10vd1tu$ekvl$1@dont-email.me> <10vel6r$l1g$1@reader1.panix.com> <10vemqf$r5qe$1@dont-email.me> <10vfsmo$16jap$1@kst.eternal-september.org> <10vgqhf$1d6tp$1@dont-email.me> <10vh074$1epj1$2@dont-email.me> <10vh1eo$1ei50$2@dont-email.me> <10vh5f0$1g1ke$1@dont-email.me> <10vhgau$1iv7l$1@dont-email.me> <10vhkgl$1k67h$1@dont-email.me> <10vie7n$1r8io$1@kst.eternal-september.org> <10vm8tj$3uus7$7@dont-email.me> <10vmimv$2tjoi$3@kst.eternal-september.org> <86ecipcbqa.fsf@linuxsc.com> <10vnlgu$382un$2@kst.eternal-september.org> <86bjdpayv0.fsf@linuxsc.com> <10vv49k$1aoa2$4@kst.eternal-september.org> <1107aq2$3grso$2@kst.eternal-september.org> <86jypr6d96.fsf@linuxsc.com> <115pmgh$3c96f$1@kst.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Sat, 29 Aug 2026 00:23:23 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2974747"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19180Oc9+IjwGel89CrrNiudipFmhSSJps="; posting-host="eb8bc6d76c2197ac12bb567debe348b2" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:4DGUaUyk6AMHPjZ9gP4vC9ViDf0= sha1:Xi6GcLHD8Ky/yzTY2w0yp2Pwy7w= sha256:bswf2AEaEpugGjyypQUuR527SjhizSYzKMLwI4V8i9E= sha1:Rp/MRpb5mGXC9JxJ9VkZnl8CKLU= sha256:MwXMIR03AW5vG5P++BhGgRKoxBSo0HDRfWucp/vXDXo= Xref: csiph.com comp.lang.c:401562 Keith Thompson writes: > Tim Rentsch writes: > >> Keith Thompson writes: >> >>> Keith Thompson writes: >>> [...] >>> >>>> The actual text of the standard implies that 42 is not an >>>> expression. I rely on the obvious intent to conclude that it is. >>> >>> I made the above statement to demonstrate that just following the >>> exact wording of the standard, without thinking about the (sometimes >>> unclear) intent behind it, can lead to absurd results. >>> >>> I've discussed this particular glitch before, but it's been a while. >>> >>> N3220 6.5.1 says: >>> >>> An *expression* is a sequence of operators and operands that >>> specifies computation of a value, or that designates an object >>> or a function, or that generates side effects, or that performs >>> a combination thereof. >>> >>> I believe the wording is unchanged from C90 up to the latest C202y >>> draft. Since the word "expression" is in italics, this is the >>> standard's definition of the word. >>> >>> This is a flawed definition. The terms "operator" and "operand" >>> are defined in 6.4.6: >>> >>> *punctuator: one of >>> [ ] ( ) >>> [snip] >>> >>> A punctuator is a symbol that has independent syntactic and >>> semantic significance. Depending on context, it may specify an >>> operation to be performed (which in turn may yield a value or a >>> function designator, produce a side effect, or some combination >>> thereof) in which case it is known as an *operator* (other forms >>> of operator also exist in some contexts). An *operand* is an >>> entity on which an operator acts. >>> >>> Consider this expression statement: >>> >>> 42; >>> >>> Is `42` an expression? Clearly it's intended to be, but there is no >>> operator, and therefore there is no operand, so it doesn't meet the >>> standard's definition of the word "expression". >> >> I think this conclusion can be explained as a misreading of the text >> in the C standard. In reading the text "An *expression* is a >> sequence of operators and operands", I think you are interpreting it >> as meaning "at least one of each of operators and operands". But >> this text could also be read as "at least one of either of operators >> and operands", or in other words a sequence of elements of the set >> containing both operands and operators, in which case 42 would >> qualify as an expression. > > No. The term "operand" is defined in N3220 6.4.6p2: > > An *operand* is an entity on which an operator acts. > > As I already explained, in the expression statement `42;`, 42 it > is neither an operator nor an operand. [...] Thank you for the explanation. Sorry for the confusion.