Given: typedef struct { void f(); } S; GCC will assume f has no linkage, because at the point of the declaration, the class is anonymous. Details at http://gcc.gnu.org/ml/gcc-patches/2002-07/threads.html#00266 Release: gcc-3.1 Environment: 3.2 as well as many (all?) older releases and newer snapshots any How-To-Repeat: Testcase is g++.old-deja/g++.oliva/linkage1.C
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. Since 3.0, the symbols's name is at least correctly named S::f, but it still has internal linkage as of today.
*** Bug 29356 has been marked as a duplicate of this bug. ***
See rejects-valid example in 29356.
*** Bug 29873 has been marked as a duplicate of this bug. ***
I mean, see rejects-valid example in bug 29873.
*** Bug 37473 has been marked as a duplicate of this bug. ***
This works correctly in recent GCC versions. Resolving as fixed. $ cat t.C && gcc -S -Wall -Wextra -Wpedantic -o/dev/stdout t.C typedef struct { void foo (); } S; void S::foo () { } .file "t.C" .text .align 2 .globl _ZN1S3fooEv .type _ZN1S3fooEv, @function _ZN1S3fooEv: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movq %rdi, -8(%rbp) nop popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size _ZN1S3fooEv, .-_ZN1S3fooEv .ident "GCC: (GNU) 7.0.1 20170223 (experimental)" .section .note.GNU-stack,"",@progbits