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.
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.
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.
10 comments
7 u/wesofx 13 Feb 2017 16:34
What about just creating a 4GB array at compile time?
5 u/Antikaon [OP] 13 Feb 2017 17:03
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 exhaustedOf 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 u/wesofx 13 Feb 2017 17:40
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 u/Antikaon [OP] 13 Feb 2017 17:43
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....
0 u/wesofx 13 Feb 2017 17:50
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 u/Antikaon [OP] 13 Feb 2017 17:56
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 u/93503847569 13 Feb 2017 15:25
is... is this clickbait?
3 u/Antikaon [OP] 13 Feb 2017 15:27
I dunno... were you baited into clicking it?
1 u/AmaleksHairyAss 13 Feb 2017 18:21
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 u/malloryquinn 13 Feb 2017 23:23
vs2010?? oh the blog is from 2013.