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: Is this code considered to transgress the signed overflow purism? Date: Sun, 30 Apr 2017 12:41:35 -0700 Organization: None to speak of Lines: 35 Message-ID: References: <11ea6682-cdee-4513-97c2-6c90b585716a@googlegroups.com> <87o9vi6rql.fsf@bsb.me.uk> <26aee5e9-ed2f-4c6e-af68-b85418c7e641@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="518c2254bac820b1cb24a1d9d6a93e31"; logging-data="23057"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MTKiEEBJ3f+y2f/6+zgkI" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:pUbIPmNhaJ3RwLtVe/O3YakLcnQ= sha1:y4IntMQOKBsbkQWj9tU7cd8mhhw= Xref: csiph.com comp.lang.c:108797 Tim Rentsch writes: [...] > For use in pre-processor conditionals, generally is > needed, because (a) sizeof doesn't work in #if etc, and (b) > even if it did, the sizes of types are potentially different in > the pre-processor than they are in the program. I'm not sure how meaningful your point (b) is. *If* the preprocessor were modified to permit sizeof, then it would be reasonable to require that for example sizeof (long) must reflect the size of type long on the target system. In fact, I'd say it would be unreasonable not to require that. (In reality, the preprocessor treats integer expressions as if they were of type intmax_t or uintmax_t. N1570 6.10.1p4.) That reminds me of a discussion on comp.std.c back in 1998. The relevant quotation: | > You are right. It was nice back in the days when things like | > | > #if (sizeof(int) == 8) | > | > actually worked (on some compilers). | | Must have been before my time. | | Dennis Yes, the poster was Dennis Ritchie. -- 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"