Path: utzoo!utgpu!watserv1!watmath!att!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.std.c Subject: Re: SIZE_T_MAX (Re: More fwrite limits) Message-ID: <17043@haddock.ima.isc.com> Date: 8 Jul 90 20:01:05 GMT References: <3159@disk.UUCP> <25096@mimsy.umd.edu> <13284@smoke.BRL.MIL> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 9 In article flee@guardian.cs.psu.edu (Felix Lee) writes: >Here are some innocuous statements that can run into trouble... To test whether (expr <= SIZE_T_MAX), where (expr) is unsigned long int, use (expr == (unsigned long int)(size_t)expr). In your example, unsigned long int sz = 1UL + strlen(a) + strlen(b); s = (sz != (unsigned long int)(size_t)sz ? NULL : malloc((size_t)sz)); Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint