This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How memcmp handles negative values for size_t


Hi All,
 
We are working on GLIBC-2.11 and GCC=4.4 a.
But while using memcmp with size as negative, it always return zero even though the memory block are different.
So I am confused about how the negative value is getting handle for glibc version 2.11.
 
But if I use the same test case with glibc-2.15 and gcc-4.6 it works fine.
So can anyone please let me know how the negative value for size is getting properly handled for glibc-2.15 and not in glibc-2.11.
Please find the attached test case for your reference.
And the command I use to build the test case is as follows:
                gcc  tc.c  -o  tc  -tcore2  -static
 
Also the assembly instruction(glibc /sysdeps/i386/i686/memcmp.S) I look is not handling the negative value, then where is the negative values getting handled.
 
It will be of great help if you provide any documented reference regarding handling negative values.

But as per what i understand the size_t is unsigned int which makes negative value to it's equivalent positive number. Even though this is the case but how the same thing is properly getting handle for glibc-2.15 and not in glibc-2.11.
 
Thanks & Regards,
Atul Kumar Singh

Attachment: tc.c
Description: tc.c


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