Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: What is the rank of size_t ? Date: Fri, 29 May 2020 20:55:12 -0700 Organization: A noiseless patient Spider Lines: 31 Message-ID: <86pnamrs9r.fsf@linuxsc.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="50ca98e22833fa004f70febc55f67ad1"; logging-data="4895"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DGuVZ9XpOvWBPVIedrXlDYCQIb2ivlPQ=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:yc1BjvJpDSDtSiYH9bWyINYrva4= sha1:Au3ii6Q11FFoyDFbPv4s7qGG+SA= Xref: csiph.com comp.lang.c:152529 Real Troll writes: > On 27/05/2020 13:49, Spiros Bousbouras wrote: > >> Specifically , if a has type int and b has type size_t , can >> a + b overflow i.e. cause undefined behaviour ? > > Try running this program to see what happens? I use 64 bit compiler on > a 64 bit machine: > > <******************************************************************> > > #include > #include > #include > #include > > int main(void) > { > const size_t N = 18446744073709551615; > int a = 100; > size_t result = N + a; > printf("SIZE_MAX is: = %zu\n", SIZE_MAX); > printf("Value of result (N + a) = %zu\n", result); > > return 0; > } > > <******************************************************************> Do you get two program errors? That's what I get.