This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c/32166] Condition check for const char string fails



------- Comment #2 from kmanjunat at gmail dot com  2007-06-01 07:52 -------
The test case is being called from a shared library with the
eabi support using dlopen.

The following is the test case

#include <stdio.h>
#include <string.h>
#include <malloc.h>


int main()
{
char *a=NULL;
char *b="abcd";
char *ret=NULL;

    ret=fun(a);
    printf("%s \n", ret);

    ret=fun(b);
    printf("%s \n", ret);

return 0;
}

Definition of fun() is in the shared library
as follows :

char *fun(str)
const char *str;
{
 int len;
 char *copy;

 if (str == NULL)
 {
   printf("Error, Null string passed \n");
   return(NULL);
 }

 len = strlen(str) + 1;

 if(!(copy = malloc(len)))
    return(NULL);

 memcpy(copy, str, len);

 return(copy);
}

The control is not getting into the condition check 
"if(str == NULL)". Ive verified this with the objdump of the 
testcase, which does not show the "cmp instruction"
for the if (str == NULL) condition checking.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32166


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