Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: dave_thompson_2@comcast.net Newsgroups: comp.lang.c Subject: Re: What is your opinion about unsigned int u = -2 ? Date: Sun, 25 Aug 2024 16:52:30 -0400 Organization: A noiseless patient Spider Lines: 16 Message-ID: <6c6ncjt5eqpnslpu583hburcu6fkgl7g6a@4ax.com> References: <87bk2cecan.fsf@bsb.me.uk> <87r0b6g3qx.fsf@nosuchdomain.example.com> <87h6c2fldh.fsf@nosuchdomain.example.com> <878qxefjk2.fsf@nosuchdomain.example.com> <87zfpue3bz.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Sun, 25 Aug 2024 22:52:39 +0200 (CEST) Injection-Info: dont-email.me; posting-host="09f9e4e3fd1f3f0a9b1d8559f78a3163"; logging-data="2199678"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2g1kWKOKq+VCC+Z5V7P6woCgpZkSbX3E=" Cancel-Lock: sha1:jG8C1sKaqwbfO63JZqsCZBTD/xM= X-Newsreader: Forte Agent 3.3/32.846 Bytes: 1942 On Fri, 02 Aug 2024 19:40:32 -0700, Keith Thompson wrote: > Thiago Adams writes: > > I think both cases (overflow and wraparound) should have warnings. > > You're free to think that, of course, but wraparound behavior is well > defined and unambiguous. I wouldn't mind an *optional* warning, but > plenty of programmers might deliberately write something like > > const unsigned int max = -1; > > with the reasonable expectation that it will set max to INT_MAX. > (cough) UINT_MAX (cough)