This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17719] New: regparm __attribute__ not set in function casts
- From: "jfran at clip dot dia dot fi dot upm dot es" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Sep 2004 23:18:04 -0000
- Subject: [Bug c/17719] New: regparm __attribute__ not set in function casts
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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