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

* [Bug web/18443] #pragma pack(1) breaks function pointer initialization
  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 ` davidm at hpl dot hp dot com
  2004-11-12  5:19 ` [Bug target/18443] " pinskia at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: davidm at hpl dot hp dot com @ 2004-11-12  5:18 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |web


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  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 ` pinskia at gcc dot gnu dot org
  2004-11-12  5:33 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-12  5:19 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|web                         |target
           Keywords|                            |wrong-code
            Version|unknown                     |3.3.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  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
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-12  5:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-12 05:33 -------
The bug is a target bug as if this is wrong the bug is in ia64_assemble_integer:

/* Target hook for assembling integer objects.  Handle word-sized
   aligned objects and detect the cases when @fptr is needed.  */

static bool
ia64_assemble_integer (rtx x, unsigned int size, int aligned_p)
{
  if (size == POINTER_SIZE / BITS_PER_UNIT
      && aligned_p                                           <--- here, aligned_p is false for this case
      && !(TARGET_NO_PIC || TARGET_AUTO_PIC)
      && GET_CODE (x) == SYMBOL_REF
      && SYMBOL_REF_FUNCTION_P (x))

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-11-12 05:33:30
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] [3.3/3.4/4.0 Regression] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (2 preceding siblings ...)
  2004-11-12  5:33 ` pinskia at gcc dot gnu dot org
@ 2004-11-12  5:49 ` pinskia at gcc dot gnu dot org
  2004-11-12  6:01 ` davidm at hpl dot hp dot com
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-12  5:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-12 05:48 -------
The bug was introduced with:
http://gcc.gnu.org/ml/gcc-patches/2001-12/msg01678.html

which looks like a mis understanding what IA64 wanted/needed.  The aligned_p there looks wrong.

So this is a regression.

Since I don't have access to an IA64 machine could you submit/regtest the patch which removes the 
aligned_p test?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |3.3.3 3.4.0 3.2 4.0.0
      Known to work|                            |3.0.4
            Summary|#pragma pack(1) breaks      |[3.3/3.4/4.0 Regression]
                   |function pointer            |#pragma pack(1) breaks
                   |initialization              |function pointer
                   |                            |initialization
   Target Milestone|---                         |3.4.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] [3.3/3.4/4.0 Regression] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (3 preceding siblings ...)
  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
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: davidm at hpl dot hp dot com @ 2004-11-12  6:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From davidm at hpl dot hp dot com  2004-11-12 06:01 -------
(In reply to comment #2)
> Since I don't have access to an IA64 machine could you submit/regtest the
patch which removes the 
> aligned_p test?

Just removing the aligned_p won't do the trick.  It's also necessary to change
data4/data8 to data4/data8.ua.  Otherwise, the data directive implicitly forces
alignment.

I _can_ do regression-testing, but am currently nested about 5 levels deep, so I
can't do it right away.  If somebody else could do it, I'd certainly greatly
appreciate it.

BTW: anybody who's willing to put their source-code on a shared machine can get
access to an IA64 machine.  Just request create an account at www.testdrive.hp.com.
The machines tend to be lightly loaded and I find them so useful that I use them
myself on occasion (for example, spe174 is currently a 4-way 1.4 GHz Itanium 2,
which should be nice for building stuff ;-).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (4 preceding siblings ...)
  2004-11-12  6:01 ` davidm at hpl dot hp dot com
@ 2004-12-05  4:34 ` 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
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-05  4:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-05 04:34 -------
Actually it looks like I was wrong in saying that it was a regression.  Also could you forward your patch 
to gcc-patches@?  Saying you added it to the bug back on the 15th of Novemeber.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|3.0.4                       |
            Summary|[3.3/3.4/4.0 Regression]    |#pragma pack(1) breaks
                   |#pragma pack(1) breaks      |function pointer
                   |function pointer            |initialization
                   |initialization              |
   Target Milestone|3.4.4                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] [3.3/3.4/4.0 Regression] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (5 preceding siblings ...)
  2004-12-05  4:34 ` [Bug target/18443] " pinskia at gcc dot gnu dot org
@ 2004-12-05 12:26 ` giovannibajo at libero dot it
  2004-12-05 15:16 ` [Bug target/18443] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: giovannibajo at libero dot it @ 2004-12-05 12:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-12-05 12:25 -------
Not until you tell us WHY it is not a regression. Did you test on ia64?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|#pragma pack(1) breaks      |[3.3/3.4/4.0 Regression]
                   |function pointer            |#pragma pack(1) breaks
                   |initialization              |function pointer
                   |                            |initialization
   Target Milestone|---                         |3.4.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (6 preceding siblings ...)
  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 ` pinskia at gcc dot gnu dot org
  2004-12-08  0:14 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-05 15:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-05 15:16 -------
Actually I was the one who said this was a regressions by looking into the CVS history but that the 
change which I said causes it was one which changed the code to be better and it was actually broken 
before that too.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.3/3.4/4.0 Regression]    |#pragma pack(1) breaks
                   |#pragma pack(1) breaks      |function pointer
                   |function pointer            |initialization
                   |initialization              |
   Target Milestone|3.4.4                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (7 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-08  0:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-08 00:14 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00489.html>.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (8 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-08  0:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-12-08 00:21 -------
Subject: Bug 18443

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2004-12-08 00:20:51

Modified files:
	gcc            : ChangeLog 
	gcc/config/ia64: ia64.c 

Log message:
	PR target/18443
	* config/ia64/ia64.c (ia64_assemble_integer): Add support for
	emitting unaligned pointer-sized integers.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6739&r2=2.6740
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.c.diff?cvsroot=gcc&r1=1.332&r2=1.333



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (9 preceding siblings ...)
  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
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-08  1:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-12-08 01:49 -------
Subject: Bug 18443

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	rth@gcc.gnu.org	2004-12-08 01:49:15

Modified files:
	gcc            : ChangeLog 
	gcc/config/ia64: ia64.c 

Log message:
	PR target/18443
	* config/ia64/ia64.c (ia64_assemble_integer): Add support for
	emitting unaligned pointer-sized integers.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.724&r2=2.2326.2.725
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.265.2.15&r2=1.265.2.16



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (10 preceding siblings ...)
  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
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-08  1:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-12-08 01:59 -------
Subject: Bug 18443

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	rth@gcc.gnu.org	2004-12-08 01:59:29

Modified files:
	gcc            : ChangeLog 
	gcc/config/ia64: ia64.c 

Log message:
	PR target/18443
	* config/ia64/ia64.c (ia64_assemble_integer): Add support for
	emitting unaligned pointer-sized integers.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.1034&r2=1.16114.2.1035
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/ia64/ia64.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.198.2.22&r2=1.198.2.23



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18443


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

* [Bug target/18443] #pragma pack(1) breaks function pointer initialization
  2004-11-12  5:16 [Bug c/18443] New: #pragma pack(1) breaks function pointer initialization davidm at hpl dot hp dot com
                   ` (11 preceding siblings ...)
  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
  12 siblings, 0 replies; 14+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-12-08  2:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-12-08 02:00 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.3.6


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).