[Bug target/20126] [3.3/3.4/4.0 Regression] Inlined memcmp makes one argument null on entry
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Feb 22 02:22:00 GMT 2005
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-21 22:15 -------
Reduced testcase (and shows that this is also a 3.3/3.4/4.0 Regression too):
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct {
struct _object *_ob_next;
struct _object *_ob_prev;
int ob_refcnt;
struct _typeobject *ob_type;
int ob_size;
long ob_shash;
int ob_sstate;
char ob_sval[1];
} strobject;
static int
string_contains(strobject *a, strobject *el)
{
const char *lhs, *rhs, *end;
int size;
size = (((el))->ob_size);
rhs = (((el))->ob_sval);
lhs = (((a))->ob_sval);
if (size == 1)
return memchr(lhs, *rhs, (((a))->ob_size)) != ((void *)0);
end = lhs + ((((a))->ob_size) - size);
while (lhs <= end) {
const char *t = lhs+1;
if (memcmp(lhs, rhs, size) == 0)
return 1;
lhs = t;
}
return 0;
}
int
main(void)
{
char* s1 = "aa";
char* s2 = "aa";
strobject *obj1;
strobject *obj2;
obj1 = calloc(1, sizeof (*obj1) + 64);
obj2 = calloc(1, sizeof (*obj2) + 64);
obj1->ob_size = strlen(s1);
obj2->ob_size = strlen(s2);
memcpy(&obj1->ob_sval[0], s1, obj1->ob_size);
memcpy(&obj2->ob_sval[0], s2, obj2->ob_size);
printf("'%*s' in '%*s' = %d\n",
obj2->ob_size, obj2->ob_sval,
obj1->ob_size, obj1->ob_sval,
string_contains(obj1, obj2));
return 0;
}
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Known to fail| |3.3.3 3.4.0 4.0.0
Known to work| |3.2.3
Last reconfirmed|0000-00-00 00:00:00 |2005-02-21 22:15:27
date| |
Summary|Inlined memcmp makes one |[3.3/3.4/4.0 Regression]
|argument null on entry |Inlined memcmp makes one
| |argument null on entry
Target Milestone|--- |3.4.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20126
More information about the Gcc-bugs
mailing list