https://gcc.gnu.org/g:6534a2407ea7e97ae59ee5e6f90c8c993d5d5258

commit r16-8552-g6534a2407ea7e97ae59ee5e6f90c8c993d5d5258
Author: Sandra Loosemore <[email protected]>
Date:   Thu Apr 9 23:43:35 2026 +0000

    doc, c++: Document that anonymous namespaces have internal linkage 
[PR124773]
    
    gcc/ChangeLog
            PR c++/124773
            * doc/trouble.texi (Linkage in Anonymous Namespaces): New section.

Diff:
---
 gcc/doc/trouble.texi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gcc/doc/trouble.texi b/gcc/doc/trouble.texi
index ad13357c30a7..4882e2fababc 100644
--- a/gcc/doc/trouble.texi
+++ b/gcc/doc/trouble.texi
@@ -638,6 +638,7 @@ give rise to questions of this sort.
 * Name lookup::         Name lookup, templates, and accessing members of base 
classes
 * Temporaries::         Temporaries may vanish before you expect
 * Copy Assignment::     Copy Assignment operators copy virtual bases twice
+* Linkage in Anonymous Namespaces::  Names have internal linkage
 @end menu
 
 @node Static Definitions
@@ -912,6 +913,21 @@ copy-assignment operator removes any uncertainties.  With 
such an
 operator, the application can define whether and how the virtual base
 subobject is assigned.
 
+@node Linkage in Anonymous Namespaces
+@subsection Linkage in Anonymous Namespaces
+
+The C++11 standard changed the linkage of anonymous namespaces from
+external (using a unique generated name) to internal.  That means that
+names declared in such a namespace now also have internal linkage, and
+@code{extern "C"} has no effect.  GCC implemented this change in
+behavior starting with the GCC 15 release; code using this idiom that
+worked in earlier versions of GCC, or with @option{-std=} options
+prior to C++11, may encounter unexpected linker issues due to changes
+in name mangling.
+
+For more information about the change to the C++ standard, see
+@uref{https://cplusplus.github.io/CWG/issues/2772.html}.
+
 @node Non-bugs
 @section Certain Changes We Don't Want to Make

Reply via email to