http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46589
Summary: struct member function not declared global Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: tempt...@freemail.hu Summary of bug: g++ doesn't declare L::G() global in the following code: typedef struct { void G() ; } L ; void L::G() { } although it does here ('typedef struct L' instead of 'typedef struct'): typedef struct L { void G() ; } L ; void L::G() { } Output from gcc -v: Using built-in specs. Target: mingw32 Configured with: ../gcc-4.4.0/configure --enable-languages=c,ada,c++,fortran,java,objc,obj-c++ --dis able-sjlj-exceptions --enable-shared --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32- registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --prefix=/mingw --with-gmp= /mingw/src/gmp/root --with-mpfr=/mingw/src/mpfr/root --build=mingw32 Thread model: win32 gcc version 4.4.0 (GCC) File main.cpp: typedef struct { void G() ; } L ; static L X ; int main() { X.G() ; } File L0.cpp: typedef struct { void G() ; } L ; void L::G() { } The command: g++ main.cpp L0.cpp This fails with: C:\...\Temp\ccCl8AUu.o:main.cpp:(.text+0x16): undefined reference to `L::G()' collect2: ld returned 1 exit status BUT: File L1.cpp has 'typedef struct' instead of 'typedef struct L': typedef struct L { void G() ; } L ; void L::G() { } g++ main.cpp L1.cpp This works! The difference can be seen in the assembly output: .file "L0.cpp" .text .align 2 .def __ZN1L1GEv; .scl 3; .type 32; .endef __ZN1L1GEv: LFB0: pushl %ebp LCFI0: movl %esp, %ebp LCFI1: leave ret LFE0: .file "L1.cpp" .text .align 2 .globl __ZN1L1GEv .def __ZN1L1GEv; .scl 2; .type 32; .endef __ZN1L1GEv: LFB0: pushl %ebp LCFI0: movl %esp, %ebp LCFI1: leave ret LFE0: __ZN1L1GEv is not declared global in L0.s.