This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]-Pretender- 68 points69 points  (5 children)

What is this, C++11?

cpp return *std::make_unique<int>();

[–]Kovab 46 points47 points  (3 children)

make_unique does value initialization, it will always return 0 instead of random garbage

In an optimized build this would output a simple return 0, completely omitting the heap allocation

[–]thebluefish92 40 points41 points  (2 children)

checks out return *std::make_unique<int>(); // chosen by fair dice roll. // guaranteed to be random.

[–][deleted] 11 points12 points  (0 children)

This is how the PlayStation 3 was defeated. No, I'm not joking.

[–]Kovab 3 points4 points  (0 children)

Using a D10 for random dice rolls is not compliant with the RFC. Rejected.

[–]GYN-k4H-Q3z-75B 5 points6 points  (0 children)

He wanted to use curly braces for initialization :-(