Windows-on-ARM-Experiments / mingw-woarm64-build

Workflows and build scripts for Windows on Arm64 GNU cross-compiler for `aarch64-w64-mingw32` target.
GNU General Public License v2.0
32 stars 4 forks source link

Object constructor not called on global static objects #180

Open Blackhex opened 2 months ago

Blackhex commented 2 months ago

Considering the following C++ code:

#include <cstdio>

class C {
public:
  C(const char *s) {
    printf(s);
  }
};

static C b("b");

namespace D {
  static C d("d");
}

int main(int argc, char **argv) {
  static C c("c");
  C a("a");
}

It outpus ca instead of bdca (or whatever is the order defined by the standard) which means that the constructors for global static objects are not called (both namespaces and non-namespaced). The local static objects' constrcutor get called.

Blackhex commented 2 months ago

Fixed by https://github.com/Windows-on-ARM-Experiments/gcc-woarm64/pull/32