Joseph Myers <jos...@codesourcery.com> writes: > On Thu, 4 Jun 2015, Richard Earnshaw wrote: > >> > Change that into >> > >> > int foo(char *s) >> > { >> > int l = strlen (s); >> > char *p = memchr (s, 'a', l); >> > return p+l; >> > } >> > >> >> Which is still meaningless if 'a' does not appear in s => when the >> result is NULL + l. >> >> In fact, unless 'a' is the first character the result is possibly >> meaningless anyway, since you can't know that p+l doesn't point more >> than one beyond the end of the object. >> >> Perhaps you just meant to return 'p'? > > And if size_t is wider than int, this function truncates the length of the > string, so still isn't particularly sensible even if returning p.
error: return makes integer from pointer without a cast Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."