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: Tue, 02 May 2017 11:26:20 -0700 Organization: None to speak of Lines: 33 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="7ecddb0005e0ed65822f61e1ca911b98"; logging-data="6042"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Zs24bNb4ySksmc45fcWJ0" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:/xtVsUAiTuvQZ58iK9qFvX/7Il8= sha1:3SMrZwLMyhTcHLyhUmImnj/3NBM= Xref: csiph.com comp.lang.c:109040 bartc writes: > On 02/05/2017 17:12, Keith Thompson wrote: >> bartc writes: >>> Anyway, I don't think this is related to whether or not a specific type, >>> rather than an evaluation of an expression, might be different in the >>> preprocessor. >> >> It is. > > How? In an ordinary expression, the constant 1U, for example, is of type unsigned int, which might commonly be 32 bits. In a preprocessor expression, it's still logically of type unsigned int, but the type unsigned int is treated as if it had the same size and representation as uintmax_t, which is commonly 64 bits. One consequence is that the expression -1U likely has a different value depending on whether or not it's part of a preprocessor expression. I frankly don't understand your question well enough to be sure that I've answered it, but in any case I think you have enough information to answer it yourself. [...] -- 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"