In bug 52477 - Wrong initialization order? attribute constructor
vs static data access, the reporter expects C++ objects with static
storage duration to have their ctors called in the same order as
those of functions declared with attribute constructor interleaved
with them.
In his comment on the bug Richard opines that relying on the order
is undefined. The attached patch updates the manual to make this
clear.
Jason, can you please review it for 7.0?
Martin
PR c++/52477 - Wrong initialization order? __attribute__((constructor)) vs static data access
gcc/ChangeLog:
PR c++/52477
* doc/extend.texi (attribute constructor): Mention order of C++ ctors.
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 143a7b7..159f1be 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2510,7 +2510,11 @@ if you have a constructor that allocates a resource and a destructor
that deallocates the same resource, both functions typically have the
same priority. The priorities for constructor and destructor
functions are the same as those specified for namespace-scope C++
-objects (@pxref{C++ Attributes}).
+objects (@pxref{C++ Attributes}). However, the order in which
+constructors for C++ objects with static storage duration and functions
+decorated with attribute @code{constructor} are invoked is unspecified.
+In mixed declarations, attribute @code{init_priority} can be used to
+impose a specific ordering.
@item deprecated
@itemx deprecated (@var{msg})