X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: Fibonacci number Date: 24 Feb 2004 13:12:22 GMT Organization: Aachen University of Technology (RWTH) Lines: 30 Message-ID: References: <4038E8CA DOT 6491815E AT virginia DOT edu> <4039DD96 DOT 3F36F3B7 AT yahoo DOT com> <200402231458 DOT i1NEwKwm020904 AT envy DOT delorie DOT com> <403A301C DOT E8F5FE65 AT yahoo DOT com> <200402231751 DOT i1NHp5lv022894 AT envy DOT delorie DOT com> NNTP-Posting-Host: ac3b07.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1077628342 3108 137.226.33.205 (24 Feb 2004 13:12:22 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 24 Feb 2004 13:12:22 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com DJ Delorie wrote: > > [#4] The subject sequence is defined as the longest initial > > subsequence of the input string, starting with the first > > non-white-space character, that is of the expected form. > ISO 9899/1999 explicitly allows '-' to be part of the expected form > for strtoul. So does C89. It explicitly mentions both signs and digits as allowed characters in the subject sequence. > Ok, *that* is a bug. Amusingly enough, glibc 2.3.2 has the same bug. I don't it's a bug. Not unless they changed this between C89 and C99. ISO C90 section 7.10.1.6 (strtoul), paragraph 5 says: If the subject sequence begins with a minus sign, the value resulting from the conversion is negated. Since negation is a well-defined operation on unsigned longs, there's no error involved. In other words: strtoul on "-1" will result in ULONG_MAX not because an error was detected, but because ULONG_MAX is the correct result of -(1UL) -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.