An example says it all: ---------------------------------------------- $ cat t.c #pragma pack (1)
typedef struct tbl_s { int (*func) (int); } TBL; static int foo (int arg) { return arg + 13; } TBL padTbl = { foo }; $ cc -S t.c $ cat t.s | tail -3 padTbl: data8.ua foo# .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-1)" ------------------------------------------ Note how the function pointer is being initialized with an ordinary reference to "foo", instead of "@fptr(foo)". As a result, any call through such a function pointer will lead to an immediate crash. This bug appears to be present in all versions of GCC which I have tested (3.2, 3.3, 3.4, and 4.0). -- Summary: #pragma pack(1) breaks function pointer initialization Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: davidm at hpl dot hp dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: ia64-linux GCC host triplet: ia64-linux GCC target triplet: ia64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443