public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization
@ 2004-11-12  5:16 davidm at hpl dot hp dot com
  2004-11-12  5:18 ` [Bug web/18443] " davidm at hpl dot hp dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: davidm at hpl dot hp dot com @ 2004-11-12  5:16 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-12-08  2:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
2004-11-12  5:18 ` [Bug web/18443] " davidm at hpl dot hp dot com
2004-11-12  5:19 ` [Bug target/18443] " pinskia at gcc dot gnu dot org
2004-11-12  5:33 ` pinskia at gcc dot gnu dot org
2004-11-12  5:49 ` [Bug target/18443] [3.3/3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
2004-11-12  6:01 ` davidm at hpl dot hp dot com
2004-12-05  4:34 ` [Bug target/18443] " pinskia at gcc dot gnu dot org
2004-12-05 12:26 ` [Bug target/18443] [3.3/3.4/4.0 Regression] " giovannibajo at libero dot it
2004-12-05 15:16 ` [Bug target/18443] " pinskia at gcc dot gnu dot org
2004-12-08  0:14 ` pinskia at gcc dot gnu dot org
2004-12-08  0:21 ` cvs-commit at gcc dot gnu dot org
2004-12-08  1:49 ` cvs-commit at gcc dot gnu dot org
2004-12-08  1:59 ` cvs-commit at gcc dot gnu dot org
2004-12-08  2:00 ` rth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).