Hola a todos !!!
Re100 me registre y espero ayudar en lo que se pueda al foro.
Depurando con la opcion -E de gcc encontre que un :
strcpy(tmp,msg());
se transforma en esta macro :
(__extension__ (__builtin_constant_p (msg()) ? (((size_t)(const void *)((msg()) + 1) - (size_t)(const
void *)(msg()) == 1) && strlen (msg()) + 1 <= 8 ? __strcpy_small (tmp, __extension__ (((__const unsigned cha
r *) (__const char *) (msg()))[0 + 1] << 8 | ((__const unsigned char *) (__const char *) (msg()))[0]), __exte
nsion__ (((__const unsigned char *) (__const char *) (msg()))[4 + 1] << 8 | ((__const unsigned char *) (__con
st char *) (msg()))[4]), __extension__ (((((__const unsigned char *) (__const char *) (msg()))[0 + 3] << 8 |
((__const unsigned char *) (__const char *) (msg()))[0 + 2]) << 8 | ((__const unsigned char *) (__const char
*) (msg()))[0 + 1]) << 8 | ((__const unsigned char *) (__const char *) (msg()))[0]), __extension__ (((((__con
st unsigned char *) (__const char *) (msg()))[4 + 3] << 8 | ((__const unsigned char *) (__const char *) (msg(
)))[4 + 2]) << 8 | ((__const unsigned char *) (__const char *) (msg()))[4 + 1]) << 8 | ((__const unsigned cha
r *) (__const char *) (msg()))[4]), strlen (msg()) + 1) : (char *) memcpy (tmp, msg(), strlen (msg()) + 1)) :
strcpy (tmp, msg())));
si se fijan puede ser PELIGROSA porque si msg() retorna memoria dinamica o si accesa a un archivo, lo hace 20 veces !!!
Solucion parche :
aux=msg();
strcpy(tmp,aux);
// o
// memcpy(tmp,aux,strlen(aux)+1);
Soluciones definivas :
1.-Saltarse esa macro, aunque no se como.
2.-Reescribir el strcpy :
//decl de string.h, asi no hay warnings
char *strcpy (char *__restrict dst, __const char *__restrict src) __THROW
//char *strcpy(char *dst, char *src)
{
if(dst == NULL || src == NULL)
{
// Se puede asignar algo a errno
return((char *)NULL);
}
//version smart
memcpy(dst,src,strlen(src)+1);
/*
//version original
while ( *src )
{
*dst++ = *src++;
}
*dst = 0;
*/
return(dst);
}
Salu2 desde Chile.