#include <stdio.h>
// tested on gcc-4.9.3 on linux gentoo amd64
// warning: compiling this will eat gigabytes of ram really fast so keep
// your CTRL-C ready
// compile with --std=c++14
struct v2f {
float x=0, y=0; // must be =0 to reproduce (probably works with other vals)
};
namespace {
struct foo {
// declaring the array like this somehow bypasses the fact that
// v2f cannot be initialized with {0}
static const size_t max_objects = 0xFFFF;
size_t num_objects; // this is not necessary, just wanted to check if it still did it when not accessing bars
v2f bars[max_objects * 255]; // the larger this array is, the longer it hangs for and the more memory it uses
};
foo f{0}; // must be initialized with {0} to reproduce
}
int main() {
printf("%ld\n", f.num_objects);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyB0ZXN0ZWQgb24gZ2NjLTQuOS4zIG9uIGxpbnV4IGdlbnRvbyBhbWQ2NAovLyB3YXJuaW5nOiBjb21waWxpbmcgdGhpcyB3aWxsIGVhdCBnaWdhYnl0ZXMgb2YgcmFtIHJlYWxseSBmYXN0IHNvIGtlZXAKLy8geW91ciBDVFJMLUMgcmVhZHkKLy8gY29tcGlsZSB3aXRoIC0tc3RkPWMrKzE0CgpzdHJ1Y3QgdjJmIHsKCWZsb2F0IHg9MCwgeT0wOyAvLyBtdXN0IGJlID0wIHRvIHJlcHJvZHVjZSAocHJvYmFibHkgd29ya3Mgd2l0aCBvdGhlciB2YWxzKQp9OwoKbmFtZXNwYWNlIHsKCXN0cnVjdCBmb28gewoJCS8vIGRlY2xhcmluZyB0aGUgYXJyYXkgbGlrZSB0aGlzIHNvbWVob3cgYnlwYXNzZXMgdGhlIGZhY3QgdGhhdCAKCQkvLyB2MmYgY2Fubm90IGJlIGluaXRpYWxpemVkIHdpdGggezB9CgkJc3RhdGljIGNvbnN0IHNpemVfdCBtYXhfb2JqZWN0cyA9IDB4RkZGRjsKCQlzaXplX3QgbnVtX29iamVjdHM7IC8vIHRoaXMgaXMgbm90IG5lY2Vzc2FyeSwganVzdCB3YW50ZWQgdG8gY2hlY2sgaWYgaXQgc3RpbGwgZGlkIGl0IHd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