Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Abstract Syntax Tree for C programs Date: Tue, 04 Jun 2019 14:37:10 -0700 Organization: None to speak of Lines: 28 Message-ID: References: <475067fe-369c-4246-84a1-05b1a3a0c6be@googlegroups.com> <5dd4672f-a571-40bc-bb1a-c14f6c631eb7@googlegroups.com> <8d90e6a8-097d-4573-a88a-1f5f56dda26d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="a9f7c3b5d2b438cdfd64a899e3119473"; logging-data="13029"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dX67eERXe5QA5iYzoeV9C" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:PEckdbX0m4R6OagcCrUH99Aa5Sw= sha1:Bl725r7EJmehE62HBFaoyjQlEuw= Xref: csiph.com comp.lang.c:144430 James Kuyper writes: [...] > Constants are things like 'a', 5, 6.0. Such initializers are not > required to be constants, they only have to be constant expressions. > 1<<31 meets all of the requirements for a valid integer constant > expression. No, it doesn't (if INT_MAX <= 2147483647). N1570 6.6p4, under Constraints: Each constant expression shall evaluate to a constant that is in the range of representable values for its type. (I find the use of the word "constant" slightly problematic, since it doesn't refer to the syntactic category "constant", but the meaning is clear enough.) One could argue either that 1<<31 is not a constant expression, or that it is a constant expression but it violates a constraint, but either way the requirement is the same: a diagnostic message is required if it's used in a context that requires a constant expression. For example rand() also meets the *syntactic* definition of a constant-expression, but it violates the constraint in 6.6p3. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */