Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: What is your opinion about unsigned int u = -2 ? Date: Fri, 02 Aug 2024 18:31:25 -0700 Organization: None to speak of Lines: 27 Message-ID: <87cymqfl3m.fsf@nosuchdomain.example.com> References: <87bk2cecan.fsf@bsb.me.uk> <87r0b6g3qx.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 03 Aug 2024 03:31:26 +0200 (CEST) Injection-Info: dont-email.me; posting-host="01c35e2bca840e4e4b0a2795d8f6c72e"; logging-data="3248403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hy0tBWfp9qwEJ7KMvh/xq" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:7MqW5x5X9G0yuvtbT2HNIu7qM8Y= sha1:wg0/TlW9VpQRV2lzIzTSdO/3yQM= Bytes: 2290 Thiago Adams writes: [...] > It is interesting to compare constexpr with the existing constant > expression in C that works with integers.Compilers extend to work with > unsigned long long. > constexpr works with the sizes as defined , for instance char. I'm not sure what you mean by "Compilers extend to work with unsigned long long.". Preprocessing expressions (used in #if conditions) are evaluated in intmax_t or uintmax_t, but that's not the case for constant expressions in general. For example, in : static const signed char c = -2; the initializer is required to be a constant expression. -2 is of type int, which is implicitly converted to char. There are no constants of types narrower than int, but you can write: static const signed char c = (signed char)-2; where `(signed char)-2` is a constant expression of type signed char. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */