News for hackers. Stuff that matters.
Re:Zeroing Memory is Hard: VC++ 2015 arrays by byuu on Monday July 18, 2016 @12:45PM (#12116233)
If you want to feel some real pain ... take the following code (simplified for posting in this thread):

    template<typename T> struct Function {
      Function() = default;
      void* callback = nullptr;
    };

    struct CPU {
      Function<void ()> functions[65536];  //= {0} makes no difference
    };

    int main() {
      CPU cpu;
      return 0;
    }
There's a bug in GCC, at least versions 5.1 - 5.4, where the above code will take 30s-90s to compile (depends on your CPU speed), and eat 500MB+ of RAM in doing it. But the bug isn't in 4.9, and possibly newer GCC releases.

What causes it? "Function() = default;" of course. Change it to "Function() {}" and the code compiles in 100ms.

So because I can't tell people, "don't use GCC 5.x", or "don't ever use any of my class objects in a large array", I basically can't use "= default;" syntax on my constructors in any of my library code now :(

There are no comments on this comment yet.