Deutsch   English   Français   Italiano  
<87cymqfl3m.fsf@nosuchdomain.example.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
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: <v8dfo9$1k7cg$1@dont-email.me>
	<pan$d2c8a$8c54ac9f$29a202e0$12c6ce86@invalid.invalid>
	<87bk2cecan.fsf@bsb.me.uk> <v8inds$2qpqh$1@dont-email.me>
	<v8iqnr$7l3c$1@news.xmission.com> <v8irje$2rolg$1@dont-email.me>
	<87r0b6g3qx.fsf@nosuchdomain.example.com>
	<v8jbj5$2us0r$4@dont-email.me> <v8jvln$33atp$1@dont-email.me>
	<v8k055$33fcl$1@dont-email.me>
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 <thiago.adams@gmail.com> 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 */