https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118982
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2025-02-22 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- How about this: --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2992,10 +2992,13 @@ the program. On some targets the attributes also accept an integer argument to specify a priority to control the order in which constructor and -destructor functions are run. A constructor -with a smaller priority number runs before a constructor with a larger -priority number; the opposite relationship holds for destructors. Note -that priorities 0-100 are reserved. So, if you have a constructor that +destructor functions are run. The @var{priority} argument is a constant +integral expression currently bounded between 101 and 65535 inclusive. +A constructor with a smaller priority number runs before a constructor with +a larger priority number; the opposite relationship holds for destructors. +Note that priorities 0-100 are reserved for use by the compiler +and its runtime libraries. +So, 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 @@ -30060,8 +30063,8 @@ initialized in an order in strict accordance with that of their definitions across translation units. However, GNU C++ allows users to control the order of initialization of objects defined at namespace scope with the @code{init_priority} attribute by specifying a relative @var{priority}, -a constant integral expression currently bounded between 101 and 65535 -inclusive. Lower numbers indicate a higher priority. +with the same meaning as for the @code{constructor} attribute +(@pxref{Common Function Attributes}). In the following example, @code{A} would normally be created before @code{B}, but the @code{init_priority} attribute reverses that order: