[Bug c/17719] New: regparm __attribute__ not set in function casts
jfran at clip dot dia dot fi dot upm dot es
gcc-bugzilla@gcc.gnu.org
Tue Sep 28 23:18:00 GMT 2004
Direct cast from void pointer to function pointer forgets about regparm
attributes (resulting a segfault). The bug does not appear if a temporal union
is used to do the cast (like in FUNCCAST0).
--
#include <stdio.h>
#define ATTR __attribute__((regparm(1)))
//#define ATTR
ATTR void f(char *s);
typedef ATTR void (*f_t)(char *s);
#define FUNCCAST0(T, X) ((union { T t; } *)&(X))->t
#define FUNCCAST1(T, X) ((T)(X))
int main() {
void *fp;
fp = f;
FUNCCAST0(f_t, fp)("ok0");
FUNCCAST1(f_t, fp)("ok1");
return 0;
}
ATTR void f(char *s) {
printf("%s\n", s);
}
--
Summary: regparm __attribute__ not set in function casts
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jfran at clip dot dia dot fi dot upm dot es
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17719
More information about the Gcc-bugs
mailing list