This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch to add builtin strncmp and builtin strncpy


 > From: "Joseph S. Myers" <jsm28@cam.ac.uk>
 > 
 > On Sun, 26 Nov 2000, Kaveh R. Ghazi wrote:
 > 
 > > strncmp(s1, "string", n) -> strcmp(s1, "string")
 > > strncmp("string", s2, n) -> strcmp("string", s2)
 > >   (where strlen("string") < n)
 > 
 > As noted on the web page, the C standard requires arguments to strcmp, but
 > not to strncmp, to be null-terminated.  If an implementation is found that
 > reads beyond the expected point in the non-constant string in strcmp, this
 > will need to be dealt with.

Sigh, I suppose it would be considered "legal" for the strcmp
implementation to call strlen on each arg before doing any
comparisons.  That would barf if s1 wasn't null terminated in the
original call to strncmp.  Perhaps that particular transformation
isn't valid, now I'm not sure.


 > 
 > The builtins need to be added to the lists in extend.texi.

Yup.  Will do.

--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]