public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24097] New: x86_64 -fPIC code gen bug (extern/static linkage confusion)
@ 2005-09-28 2:37 mcoiley at yahoo dot com
2005-09-28 2:48 ` [Bug c/24097] [3.4 Regression] " pinskia at gcc dot gnu dot org
2005-09-28 18:49 ` mcoiley at yahoo dot com
0 siblings, 2 replies; 7+ messages in thread
From: mcoiley at yahoo dot com @ 2005-09-28 2:37 UTC (permalink / raw)
To: gcc-bugs
With this testcase:
int foo (int (*cb)(void)) { return (*cb)(); }
static int callback(void) { return 0; }
int main (void)
{
int callback (void);
return foo (callback);
}
On x86_64 with -fPIC, the address of callback as passed to foo is incorrect.
If callback isn't static, it works (through the GOT). If the declaration of
callback is removed it works (computes the address as %rip minus something). As
written, it does a failed combination of the two. The result is that instead of
passing callback's address, it loads the first 8 bytes at callback's address and
passes those. (It also erroneously claims callback is unused, but I'm guessing
that's a side-effect.)
The code is questionable, but my reading of the standard says it's legal and
that callback is still static after the (implicitly extern) declaration.
% gcc-3.4.4 -O2 -fPIC -Wall -save-temps -o bug bug.c
bug.c:2: warning: 'callback' defined but not used
% gcc-3.4.4 -v
Reading specs from /usr/local/lib/gcc/x86_64-pc-linux-gnu/3.4.4/specs
Configured with: /tmp/src/gcc-3.4.4/configure --enable-languages=c,c++
--enable-version-specific-runtime-libs --disable-shared --enable-threads
--with-gnu-as --with-gnu-ld --with-pic --host=x86_64-pc-linux-gnu
Thread model: posix
gcc version 3.4.4
[I bootstrapped this 3.4.4; it also fails with stock 3.4.3 from RedHat.]
--
Summary: x86_64 -fPIC code gen bug (extern/static linkage
confusion)
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mcoiley at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: x86_64-pc-linux-gnu
GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24097
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/24097] [3.4 Regression] x86_64 -fPIC code gen bug (extern/static linkage confusion)
2005-09-28 2:37 [Bug c/24097] New: x86_64 -fPIC code gen bug (extern/static linkage confusion) mcoiley at yahoo dot com
@ 2005-09-28 2:48 ` pinskia at gcc dot gnu dot org
2005-09-28 18:49 ` mcoiley at yahoo dot com
1 sibling, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-28 2:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-09-28 02:48 -------
Confirmed, only a 3.4 regression.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
GCC build triplet|x86_64-pc-linux-gnu |
GCC host triplet|x86_64-pc-linux-gnu |
Keywords| |wrong-code
Known to fail| |3.4.0 3.4.5
Known to work| |3.3.3 4.0.0 4.1.0
Last reconfirmed|0000-00-00 00:00:00 |2005-09-28 02:48:38
date| |
Summary|x86_64 -fPIC code gen bug |[3.4 Regression] x86_64 -
|(extern/static linkage |fPIC code gen bug
|confusion) |(extern/static linkage
| |confusion)
Target Milestone|--- |3.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24097
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/24097] [3.4 Regression] x86_64 -fPIC code gen bug (extern/static linkage confusion)
2005-09-28 2:37 [Bug c/24097] New: x86_64 -fPIC code gen bug (extern/static linkage confusion) mcoiley at yahoo dot com
2005-09-28 2:48 ` [Bug c/24097] [3.4 Regression] " pinskia at gcc dot gnu dot org
@ 2005-09-28 18:49 ` mcoiley at yahoo dot com
1 sibling, 0 replies; 7+ messages in thread
From: mcoiley at yahoo dot com @ 2005-09-28 18:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mcoiley at yahoo dot com 2005-09-28 18:49 -------
*** Bug 24106 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24097
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/24097] [3.4 Regression] x86_64 -fPIC code gen bug (extern/static linkage confusion)
[not found] <bug-24097-11429@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2006-02-14 0:19 ` pinskia at gcc dot gnu dot org
@ 2006-03-01 4:50 ` gdr at gcc dot gnu dot org
3 siblings, 0 replies; 7+ messages in thread
From: gdr at gcc dot gnu dot org @ 2006-03-01 4:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from gdr at gcc dot gnu dot org 2006-03-01 04:50 -------
Fixed in 4.0.0 and up.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|3.4.6 |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24097
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/24097] [3.4 Regression] x86_64 -fPIC code gen bug (extern/static linkage confusion)
[not found] <bug-24097-11429@http.gcc.gnu.org/bugzilla/>
2005-10-07 4:14 ` gdr at gcc dot gnu dot org
2006-02-14 0:17 ` pinskia at gcc dot gnu dot org
@ 2006-02-14 0:19 ` pinskia at gcc dot gnu dot org
2006-03-01 4:50 ` gdr at gcc dot gnu dot org
3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-14 0:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2006-02-14 00:19 -------
IIRC this was fixed by a latter rewrite of c-decl.c and most likely not going
to be fixed for 3.4.x.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24097
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/24097] [3.4 Regression] x86_64 -fPIC code gen bug (extern/static linkage confusion)
[not found] <bug-24097-11429@http.gcc.gnu.org/bugzilla/>
2005-10-07 4:14 ` gdr at gcc dot gnu dot org
@ 2006-02-14 0:17 ` pinskia at gcc dot gnu dot org
2006-02-14 0:19 ` pinskia at gcc dot gnu dot org
2006-03-01 4:50 ` gdr at gcc dot gnu dot org
3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-14 0:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-02-14 00:17 -------
*** Bug 26271 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |josh dot parsons at stonebow
| |dot otago dot ac dot nz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24097
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/24097] [3.4 Regression] x86_64 -fPIC code gen bug (extern/static linkage confusion)
[not found] <bug-24097-11429@http.gcc.gnu.org/bugzilla/>
@ 2005-10-07 4:14 ` gdr at gcc dot gnu dot org
2006-02-14 0:17 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-10-07 4:14 UTC (permalink / raw)
To: gcc-bugs
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.5 |3.4.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24097
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-03-01 4:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-28 2:37 [Bug c/24097] New: x86_64 -fPIC code gen bug (extern/static linkage confusion) mcoiley at yahoo dot com
2005-09-28 2:48 ` [Bug c/24097] [3.4 Regression] " pinskia at gcc dot gnu dot org
2005-09-28 18:49 ` mcoiley at yahoo dot com
[not found] <bug-24097-11429@http.gcc.gnu.org/bugzilla/>
2005-10-07 4:14 ` gdr at gcc dot gnu dot org
2006-02-14 0:17 ` pinskia at gcc dot gnu dot org
2006-02-14 0:19 ` pinskia at gcc dot gnu dot org
2006-03-01 4:50 ` gdr 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).