10 comments

7

What about just creating a 4GB array at compile time?

constexpr int a[0xffffffff] = {}; int main(){}
5

Interesting... I have 16gb of RAM (and 8gb swap) and I can't successfully compile it.

g++ creates an object file with 17,179,869,671 bytes, but it fails to link:

/usr/bin/ld: final link failed: Memory exhausted

Of course, I think the point was that the code in question shouldn't compile at all and it used 4gb just trying because of a compiler bug.

1

Lol I didn't even consider an int being 4 bytes. And the article is interesting. I'd never really thought about the compiler itself having to deal with memory constraints. PS I thought that code compiled, but maybe I compiled the wrong thing.

0

Your example compiles fine (or... it would if you have the memory I think).

I meant the code in the article that the compiler choked on....

void test()
{
    __asm { add eax 
    __asm { add eax
}
0

It looks like it's missing the }'s. Are they implicit? Is that standard? I've never written assembly let alone assembly inside a c++ program.

1

No, it's not valid code. Visual Studio’s C++ compiler had a bug that caused it to go into an infinite loop allocating memory when it hit certain invalid inline assembly like that.

BTW, assembly is fun.

1

is... is this clickbait?

3

I dunno... were you baited into clicking it?

1

Obviously it's somehow misinterpreting the extra opening curly bracket. __asm is an intrinsic function call, so it has to have been turned into an infinite recursion.

1

vs2010?? oh the blog is from 2013.