Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 11 Feb 2012 18:18:28 -0600 Message-ID: <4F370555.7387@mindspring.com> Date: Sat, 11 Feb 2012 19:18:29 -0500 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: return -1 using size_t??? References: <8c1eef8c-2ba4-441e-aa86-36486b56a261@n12g2000yqb.googlegroups.com> <65729073-738d-4faf-9cbd-20e020532949@p7g2000yqk.googlegroups.com> <4f36efde$0$6935$e4fe514c@news2.news.xs4all.nl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 32 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.156.228.180 X-Trace: sv3-lze4Rvf2y2a5Sgcr66L6xvtjOS/ZasXXEL/IdxFx9v/kQaG7uM+2vazqB+yd5bmWlwmhHcJYuf6aV7q!SfGm1gRDc/hAgeaDLJtSA7URzKU7mVo713zoSOUT5wYPQFKgt3FYdJCGiT0efrQF3MWu/FQrneRc!uXH22oHHR2Y= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2348 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:17160 Jeroen Mostert wrote: > > On 2012-02-11 23:25, Jeffrey R wrote: > > A size_t is an UN-SIGNED type, > > trying to store a negative number in it is > > a programmer error generating an undefined behavior. > > (size_t) -1 is well-defined on any C implementation, > per section 6.3.1.3p2 > of the standard. > It's equal to the maximum value a size_t can hold. This > does not depend on the underlying representation. I'll post the text, just in case Jeffrey R thinks that you're making this up. 6.3.1.3 Signed and unsigned integers 1 When a value with integer type is converted to another integer type other than _Bool, if the value can be represented by the new type, it is unchanged. 2 Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.60) 60) The rules describe arithmetic on the mathematical value, not the value of a given type of expression. -- pete