https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94810
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- No. The ambiguity only happens if you use the attribute explicitly, as you are doing. Just create a global object with a constructor and a destructor, instead of using functions with __attribute__((constructor)) and __attribute__((destructor)). #include <iostream> struct X { X() { std::cout << "Starting" << std::endl; } ~X() { std::cout << "Finishing" << std::endl; } }; int main() { std::cout << "Hello, World!" << std::endl; } I'm closing this as invalid, since the attribute is documented to have unspecified construction order relative to normal globals, which means your original example is not expected to work.