[Bug c/32166] Condition check for const char string fails
kmanjunat at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jun 1 07:52:00 GMT 2007
------- 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
More information about the Gcc-bugs
mailing list