------- Comment #2 from rguenth at gcc dot gnu dot org 2009-02-14 17:03 ------- 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. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39179