This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/39179] Wrong code in c++ for const members initialized in external file
- From: "ktietz at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Feb 2009 20:10:11 -0000
- Subject: [Bug target/39179] Wrong code in c++ for const members initialized in external file
- References: <bug-39179-15155@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from ktietz at gcc dot gnu dot org 2009-02-14 20:10 -------
(In reply to comment #2)
> The problem is that targetm.binds_local_p returns true for
>
> <var_decl 0xb7866000 k
> type <integer_type 0xb785edd0 unsigned int readonly unsigned SI
> size <integer_cst 0xb778b4a4 constant 32>
> unit size <integer_cst 0xb778b1f8 constant 4>
> align 32 symtab 0 alias set -1 canonical type 0xb785edd0 precision 32
> min <integer_cst 0xb778b4c8 0> max <integer_cst 0xb778b480 4294967295>>
> readonly used public static unsigned external nonlocal decl_3 decl_5 decl_6
> SI file t.ii line 2 col 27 size <integer_cst 0xb778b4a4 32> unit size
> <integer_cst 0xb778b1f8 4>
> align 32 context <record_type 0xb785ec30 K>
> chain <type_decl 0xb785ed00 K>>
>
> though probably nobody thought of handling TREE_STATIC && DECL_EXTERNAL being
> true at the same time. Thus, this looks like a possible C++ FE problem to me?
>
> A simple fix would be for i386_pe_binds_local_p to return false if
> DECL_EXTERNAL is set, as this is what default_binds_local_p_1 does.
> Or better, it should dispatch to default_binds_local_p_1 and only
> adjust the shlib flag according to DECL_DLLIMPORT_P.
>
Right in winnt.c (i386_pe_bind_local_p) should be something like this patch,
but sadly we get then emitted @GOTPCREL, which aren't handled proper by COFF
targets.
Index: gcc/gcc/config/i386/winnt.c
===================================================================
--- gcc.orig/gcc/config/i386/winnt.c
+++ gcc/gcc/config/i386/winnt.c
@@ -321,13 +321,14 @@ i386_pe_encode_section_info (tree decl,
bool
i386_pe_binds_local_p (const_tree exp)
{
+ bool flag = true;
/* PE does not do dynamic binding. Indeed, the only kind of
non-local reference comes from a dllimport'd symbol. */
if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
&& DECL_DLLIMPORT_P (exp))
- return false;
+ flag = false;
- return true;
+ return flag && default_binds_local_p_1 (exp, flag_shlib);
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39179