0% found this document useful (0 votes)
99 views187 pages

Objectlifetimepuzzlers Book1

Object Lifetime Puzzlers Book 1 by Jason Turner contains 128 fun puzzles focused on understanding object lifetimes in C++. The book introduces four types of object lifetimes: automatic, static, thread_local, and dynamic, explaining their rules and providing real C++ code examples. It aims to engage C++ programmers through puzzles that enhance their knowledge of object lifetime concepts.

Uploaded by

dofoce9626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views187 pages

Objectlifetimepuzzlers Book1

Object Lifetime Puzzlers Book 1 by Jason Turner contains 128 fun puzzles focused on understanding object lifetimes in C++. The book introduces four types of object lifetimes: automatic, static, thread_local, and dynamic, explaining their rules and providing real C++ code examples. It aims to engage C++ programmers through puzzles that enhance their knowledge of object lifetime concepts.

Uploaded by

dofoce9626
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Object Lifetime Puzzlers Book 1

128 Fun Puzzles

Jason Turner
This book is for sale at [Link]

This version was published on 2022-01-19

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing
process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools
and many iterations to get reader feedback, pivot until you have the right book and build
traction once you do.

© 2021 - 2022 Jason Turner


The Land Of Objects
Welcome to the land of objects. In this land, objects say their first name when their lifetime
begins, and say their last name when their lifetime ends.
We have four different types of object lifetimes that we will eventually encounter.

• automatic
• static
• thread_local
• dynamic

Each type of lifetime has its own rules for when the lifetime begins and lifetime ends, and we’ll
explain them as we get to them!

Object Declaration

Every object in our land looks like this:

S object_1("First Name", "Last Name");

• S: The object’s Type


• object_1: The object’s ID
• "First Name": The object’s first name
• "Last Name": The object’s last name

Important note:
Anything starting with // is a “comment” and has no impact on the code!

A Note On Puzzle Layout

Some puzzles split across pages. Sometimes this is annoying. I’ve decided to leave it how it is
because it adds a sense of realism to what it’s actually like to read unnecessarily complex C++
code.

1
The Land Of Objects 2

How C++ Relates

Each of these examples are real C++ code. If you are a C++ user, you can learn more about object
lifetime with these puzzles.
These puzzles come directly from classes that I teach with C++ programmers. If you find them
interesting, contact me about training. [Link]
Each solution is a topic that has something to do with C++. If you cannot figure out what the
solution means, then duckduckgo for it and learn something new :).
If you aren’t a C++ user then don’t worry about any of this, just have fun!
Automatic Lifetime
Automatic lifetime is the default. Objects with automatic lifetime have their lifetime begin
when their ID is first seen, and their lifetime end when their ID is no longer visible (after the
ending }).

void run() {
S object_1("1", "2");
}

When this code is run, this is what happens:

void run() {
S object_1("1", "2"); // 1 is printed
} // 2 is printed, object_1 is no longer visible

The output is:

12

Objects’ lifetimes end in the reverse order they begin:

void run() {
S object_1("1", "2");
S object_2("3", "4");
}

When this code is run, this is what happens:

void run() {
S object_1("1", "2"); // 1 is printed
S object_2("3", "4"); // 3 is printed
} // 4 is printed, object_2's lifetime ends first
// 2 is printed, object_1's lifetime ends second

The output is:

3
Automatic Lifetime 4

1342

We can introduce a new “scope” with a {. Now remember, an “automatic” object’s lifetime
ends when its ID is no longer visible. When it “goes out of scope.”

void run() {
{
S object_1("1", "2");
}
S object_2("3", "4");
}

When this code is run, this is what happens:

void run() {
{
S object_1("1", "2"); // 1
} // 2
S object_2("3", "4"); // 3
} // 4

The output is:

1234
Automatic Lifetime Puzzles
Puzzle 1

void run() {
S object_1("p", "s");
S object_2("l", "u");
}

Answer (4):

__ __ __ __

Puzzle 2

void run() {
{
S object_1("s", "l");
{
S object_2("t", "r");
}
S object_3("t", "o");
}
}

Answer (6):

__ __ __ __ __ __

Puzzle 3

void run() {
{
{
S object_1("p", "a");
}
S object_2("c", "k");
}
S object_3("a", "d");
S object_4("g", "e");

5
Automatic Lifetime Puzzles 6

Answer (8):

__ __ __ __ __ __ __ __

Puzzle 4

void run() {
{
S object_1("w", "e");
}
{
S object_2("a", "k");
}
{
S object_3("_", "o");
}
S object_4("r", "r");
S object_5("d", "e");
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 5

void run() {
{
{
S object_1("i", "r");
{
S object_2("s", "_");
}
S object_3("p", "a");
}
S object_4("t", "i");
}
S object_5("t", "d");
S object_6("i", "e");
S object_7("o", "n");
}
Automatic Lifetime Puzzles 7

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 6

void run() {
{
S object_1("s", "u");
{
S object_2("e", "_");
{
S object_3("t", "w");
{
S object_4(":", ":");
}
S object_5("l", "o");
}
S object_6("e", "r");
}
S object_7("b", "o");
}
S object_8("n", "d");
}

Answer (16):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 7

void run() {
{
S object_1("e", "q");
}
{
S object_2("u", "a");
}
{
S object_3("l", "_");
}
{
Automatic Lifetime Puzzles 8

S object_4("t", "o");
}
S object_5(":", "r");
S object_6(":", "o");
S object_7("o", "t");
S object_8("p", "a");
S object_9("e", "r");
}

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 8

void run() {
S object_1("w", "e");
S object_2("e", "l");
{
S object_3("a", "k");
}
S object_4("l", "b");
{
S object_5("y", "_");
}
{
S object_6("i", "n");
}
S object_7("c", "a");
{
S object_8("r", "t");
{
S object_9("e", "m");
}
S object_10("e", "n");
}
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Static Lifetime
Static objects, like automatic objects, have their lifetime begin the first time their ID is seen.
Their lifetime ends not when they go out of scope, but instead when the program ends.
Objects’ lifetimes still end in the reverse order they begin:

void run() {
static S object_1("1", "2");
static S object_1("3", "4");
}

When this code is run, this is what happens:

void run() {
static S object_1("1", "2"); // 1 is printed
static S object_2("3", "4"); // 3 is printed
}

// Program Ends

// 4 is printed, object_2's lifetime ends first


// 2 is printed, object_1's lifetime ends second

The output is:

1342

Scopes do not impact static objects in the same way they impact automatic objects.

void run() {
{
static S object_1("1", "2");
}
static S object_2("3", "4");
}

When this code is run, this is what happens:

9
Static Lifetime 10

void run() {
{
static S object_1("1", "2"); // 1
}
static S object_2("3", "4"); // 3
}

// Program ends

// object_2's lifetime ends: 4


// object_1's lifetime ends: 2

The output is:

1342
Static Lifetime Puzzles
Puzzle 9

void run() {
static S object_1("f", "s");
{
static S object_2("g", "w");
}
static S object_3("e", "t");
}

Answer (6):

__ __ __ __ __ __

Puzzle 10

void run() {
{
static S object_1("d", "e");
}
static S object_2("i", "t");
static S object_3("s", "e");
static S object_4("c", "r");
}

Answer (8):

__ __ __ __ __ __ __ __

11
Static Lifetime Puzzles 12

Puzzle 11

void run() {
static S object_1("u", "d");
{
static S object_2("n", "e");
{
static S object_3("e", "t");
}
static S object_4("x", "c");
}
static S object_5("p", "e");
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 12

void run() {
{
static S object_1("m", "t");
{
static S object_2("a", "c");
}
static S object_3("p", "a");
}
static S object_4(":", "r");
static S object_5(":", "t");
static S object_6("e", "x");
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __
Static Lifetime Puzzles 13

Puzzle 13
void run() {
{
static S object_1("U", "t");
{
static S object_2("n", "i");
}
static S object_3("a", "a");
{
static S object_4("r", "r");
}
static S object_5("y", "T");
}
static S object_6("T", "e");
static S object_7("y", "p");
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 14
void run() {
{
{
static S object_1("p", "N");
}
{
static S object_2("l", "_");
}
static S object_3("a", ":");
}
static S object_4("c", ":");
static S object_5("e", "s");
static S object_6("h", "r");
static S object_7("o", "e");
static S object_8("l", "d");
}

Answer (16):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Static Lifetime Puzzles 14

Puzzle 15

void run() {
{
static S object_1("i", "e");
}
static S object_2("n", "p");
{
static S object_3("t", "y");
}
{
static S object_4("e", "t");
}
{
static S object_5("g", " ");
}
static S object_6("e", "s");
static S object_7("r", "s");
static S object_8("-", "a");
static S object_9("c", "l");
}

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 16

void run() {
static S object_1("i", "v");
static S object_2("s", "_");
{
static S object_3("_", "e");
}
static S object_4("m", "l");
{
static S object_5("o", "b");
{
static S object_6("v", "a");
{
static S object_7("e", "n");
}
static S object_8("_", "g");
Static Lifetime Puzzles 15

}
static S object_9("a", "i");
}
static S object_10("s", "s");
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 17

void run() {
{
static S object_1("t", "t");
}
S object_2("i", "e");
static S object_3("m", "_");
}

Answer (6):

__ __ __ __ __ __

Puzzle 18

void run() {
static S object_1("u", "t");
{
static S object_2("i", "_");
}
static S object_3("n", "2");
S object_4("t", "3");
}

Answer (8):

__ __ __ __ __ __ __ __
Static Lifetime Puzzles 16

Puzzle 19

void run() {
S object_1("r", "i");
static S object_2("a", "n");
{
S object_3("n", "g");
}
S object_4("e", ":");
{
S object_5("s", ":");
}
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 20

void run() {
S object_1("s", "d");
S object_2("t", "r");
{
S object_3("r", "o");
}
{
S object_4("n", "_");
static S object_5("g", "r");
}
static S object_6("o", "e");
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __
Static Lifetime Puzzles 17

Puzzle 21

void run() {
static S object_1("o", "r");
S object_2("v", "r");
static S object_3("e", "o");
{
S object_4("r", "f");
}
S object_5("l", "e");
static S object_6("o", "r");
S object_7("w", "_");
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 22

void run() {
{
{
S object_1("c", "b");
{
static S object_2("t", "k");
S object_3("y", "p");
}
S object_4("e", "_");
}
S object_5("a", ":");
static S object_6("s", "s");
S object_7("e", ":");
}
S object_8("m", "a");
}

Answer (16):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Static Lifetime Puzzles 18

Puzzle 23

void run() {
{
{
S object_1("t", "_");
{
static S object_2("h", "d");
}
S object_3("i", "s");
}
static S object_4("t", "l");
{
S object_5("h", ":");
static S object_6("r", "e");
S object_7("e", "d");
static S object_8("a", "i");
}
S object_9(":", "y");
}
}

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 24

void run() {
{
{
static S object_1("r", "e");
}
{
static S object_2("a", "g");
}
S object_3("n", "g");
}
S object_4("e", "o");
{
static S object_5("s", "n");
}
static S object_6(":", "a");
Static Lifetime Puzzles 19

static S object_7(":", "r");


S object_8("c", "m");
static S object_9("o", "_");
static S object_10("m", "n");
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Dynamic Lifetime
Dynamic objects have their lifetimes begin when a new expression is executed, and their life-
times end when a delete expression is executed.

void run() {
S *object_1 = nullptr;
}

The above example has 1 pointer and no new and no delete, so there’s nothing to print!
Note: the astute among you will notice that there is still an object here. object_1 is a trivial
object with a type of S *.

void run() {
S *object_1 = new S("1", "2");
delete S;
}

When this code is executed:

void run() {
S *object_1 = new S("1", "2"); // 1
delete S; // 2
}

Dynamic objects can mess with our notion of when objects’ lifetimes begin and end:

void run() {
S *object_1 = new S("1", "2"); // 1
S *object_2 = new S("3", "4"); // 3
delete object_1; // 2
delete object_2; // 4
}

20
Dynamic Lifetime Puzzles
Puzzle 25

void run() {
S *object_1 = new S("l", "c");
S *object_2 = nullptr;
object_2 = new S("o", "g");
delete object_1;
S *object_3 = new S("k", "y");
}

Answer (4):

__ __ __ __

Puzzle 26

void run() {
{
S *object_1 = nullptr;
S *object_2 = new S("i", "l");
}
S *object_3 = nullptr;
S *object_4 = new S("f", "b");
}

Answer (2):

__ __

21
Dynamic Lifetime Puzzles 22

Puzzle 27

void run() {
S *object_1 = nullptr;
object_1 = new S("b", "x");
S *object_2 = new S("a", "v");
S *object_3 = nullptr;
{
S *object_4 = new S("d", "e");
S *object_5 = nullptr;
}
}

Answer (3):

__ __ __

Puzzle 28

void run() {
S *object_1 = nullptr;
{
object_1 = new S("s", "t");
delete object_1;
}
S *object_2 = nullptr;
S *object_3 = new S("r", "n");
{
S *object_4 = nullptr;
}
object_2 = new S("c", "s");
delete object_2;
S *object_5 = new S("p", "e");
delete object_3;
S *object_6 = nullptr;
}

Answer (7):

__ __ __ __ __ __ __
Dynamic Lifetime Puzzles 23

Puzzle 29

void run() {
S *object_1 = nullptr;
{
S *object_2 = nullptr;
{
object_1 = new S("d", "c");
S *object_3 = nullptr;
{
object_2 = new S("e", "v");
S *object_4 = nullptr;
delete object_1;
object_3 = new S("l", "l");
}
delete object_2;
S *object_5 = new S("a", "o");
S *object_6 = nullptr;
delete object_3;
S *object_7 = nullptr;
}
}
}

Answer (7):

__ __ __ __ __ __ __

Puzzle 30

void run() {
S *object_1 = nullptr;
{
}
S *object_2 = new S("s", "j");
object_1 = new S("w", "l");
{
S *object_3 = new S("i", "g");
S *object_4 = nullptr;
{
S *object_5 = new S("t", "c");
S *object_6 = nullptr;
object_4 = new S("c", "v");
Dynamic Lifetime Puzzles 24

S *object_7 = nullptr;
S *object_8 = new S("h", "u");
}
}
}

Answer (6):

__ __ __ __ __ __

Puzzle 31

void run() {
S *object_1 = nullptr;
{
S *object_2 = new S("b", "d");
{
S *object_3 = new S("a", "n");
delete object_2;
S *object_4 = new S("_", "c");
object_1 = new S("a", "v");
delete object_3;
S *object_5 = nullptr;
object_5 = new S("y", "s");
S *object_6 = new S("_", "r");
delete object_4;
{
S *object_7 = new S("a", "j");
delete object_5;
{
S *object_8 = nullptr;
S *object_9 = new S("t", "m");
}
}
}
}
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 25

Puzzle 32

void run() {
{
S *object_1 = nullptr;
object_1 = new S("T", "f");
S *object_2 = new S("r", "v");
S *object_3 = nullptr;
{
object_3 = new S("i", "j");
delete object_2;
}
S *object_4 = nullptr;
}
S *object_5 = nullptr;
S *object_6 = nullptr;
S *object_7 = new S("i", "n");
{
object_5 = new S("a", "q");
S *object_8 = new S("l", "i");
}
{
S *object_9 = new S("T", "k");
object_6 = new S("y", "p");
}
delete object_6;
S *object_10 = new S("e", "k");
}

Answer (11):

__ __ __ __ __ __ __ __ __ __ __

Puzzle 33

void run() {
S *object_1 = new S("m", "h");
S *object_2 = nullptr;
S *object_3 = new S("i", "g");
object_2 = new S("c", "w");
S *object_4 = new S("r", "d");
S *object_5 = new S("o", "x");
}
Dynamic Lifetime Puzzles 26

Answer (5):

__ __ __ __ __

Puzzle 34

void run() {
{
S object_1("l", "c");
S *object_2 = new S("o", "q");
S *object_3 = nullptr;
}
S *object_4 = new S("a", "q");
S object_5("l", "e");
S *object_6 = nullptr;
}

Answer (6):

__ __ __ __ __ __

Puzzle 35

void run() {
{
}
{
S *object_1 = nullptr;
S object_2("g", "e");
}
S object_3("t", "r");
S *object_4 = new S("c", "r");
S *object_5 = new S("h", "m");
S *object_6 = new S("a", "y");
}

Answer (7):

__ __ __ __ __ __ __
Dynamic Lifetime Puzzles 27

Puzzle 36
void run() {
{
S *object_1 = new S("f", "h");
{
S *object_2 = nullptr;
S object_3("t", "e");
}
S *object_4 = nullptr;
}
S object_5("l", "l");
S *object_6 = nullptr;
S *object_7 = nullptr;
}

Answer (5):

__ __ __ __ __

Puzzle 37
void run() {
S *object_1 = new S("s", "a");
{
S object_2("p", "e");
{
delete object_1;
{
S object_3("n", "t");
S *object_4 = nullptr;
S *object_5 = new S("s", "w");
}
S *object_6 = nullptr;
object_6 = new S("r", "j");
}
}
S object_7("a", "m");
S *object_8 = nullptr;
}

Answer (10):

__ __ __ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 28

Puzzle 38

void run() {
{
{
S *object_1 = nullptr;
object_1 = new S("l", "d");
S object_2("o", "a");
S *object_3 = nullptr;
object_3 = new S("c", "h");
}
{
}
S *object_4 = new S("l", "u");
}
S object_5("e", "d");
S *object_6 = new S(":", "i");
S *object_7 = new S(":", "a");
S *object_8 = nullptr;
delete object_6;
S *object_9 = nullptr;
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 39

void run() {
S *object_1 = new S("c", "h");
{
S object_2("o", "n");
S *object_3 = new S("n", "b");
S object_4("d", "o");
S *object_5 = nullptr;
S *object_6 = new S("i", "u");
object_5 = new S("t", "d");
S *object_7 = nullptr;
{
S *object_8 = new S("i", "p");
S *object_9 = nullptr;
}
Dynamic Lifetime Puzzles 29

}
}

Answer (9):

__ __ __ __ __ __ __ __ __

Puzzle 40

void run() {
{
S object_1("i", "n");
}
{
}
S *object_2 = new S("c", "l");
S *object_3 = nullptr;
delete object_2;
{
S object_4("u", "_");
S *object_5 = new S("s", "r");
S object_6("i", "e");
object_3 = new S("v", "l");
}
S *object_7 = new S("s", "s");
{
S *object_8 = new S("c", "r");
S object_9("a", "n");
S *object_10 = nullptr;
}
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 30

Puzzle 41

void run() {
{
static S object_1("m", "e");
S *object_2 = new S("k", "t");
S *object_3 = nullptr;
delete object_2;
}
S *object_4 = new S("i", "m");
delete object_4;
S *object_5 = nullptr;
}

Answer (6):

__ __ __ __ __ __

Puzzle 42

void run() {
static S object_1("s", "m");
{
static S object_2("s", "a");
}
S *object_3 = new S("t", "u");
S *object_4 = nullptr;
static S object_5("r", "e");
S *object_6 = nullptr;
}

Answer (7):

__ __ __ __ __ __ __
Dynamic Lifetime Puzzles 31

Puzzle 43

void run() {
{
S *object_1 = new S("n", "m");
static S object_2("u", "t");
{
delete object_1;
S *object_3 = nullptr;
object_3 = new S("p", "a");
}
static S object_4("u", "c");
}
S *object_5 = new S("n", "v");
S *object_6 = nullptr;
}

Answer (8):

__ __ __ __ __ __ __ __

Puzzle 44

void run() {
{
}
{
S *object_1 = nullptr;
}
static S object_2("c", "t");
S *object_3 = new S("h", "3");
S *object_4 = nullptr;
object_4 = new S("a", "r");
static S object_5("r", "_");
S *object_6 = nullptr;
delete object_3;
S *object_7 = new S("2", "a");
}

Answer (8):

__ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 32

Puzzle 45

void run() {
S *object_1 = new S("R", "e");
{
delete object_1;
S *object_2 = new S("g", "l");
S *object_3 = nullptr;
object_3 = new S("e", "r");
static S object_4("x", "s");
S *object_5 = nullptr;
object_5 = new S("T", "j");
S *object_6 = nullptr;
delete object_3;
S *object_7 = nullptr;
object_6 = new S("a", "u");
static S object_8("i", "t");
}
}

Answer (11):

__ __ __ __ __ __ __ __ __ __ __

Puzzle 46

void run() {
static S object_1("a", "e");
{
S *object_2 = nullptr;
{
S *object_3 = nullptr;
static S object_4("n", "u");
S *object_5 = new S("y", "_");
S *object_6 = nullptr;
object_3 = new S(":", "h");
{
object_2 = new S(":", "v");
delete object_3;
object_6 = new S("a", "p");
S *object_7 = new S("s", "b");
}
delete object_5;
Dynamic Lifetime Puzzles 33

delete object_2;
}
S *object_8 = nullptr;
}
static S object_9("a", "l");
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 47

void run() {
{
S *object_1 = nullptr;
}
S *object_2 = new S("i", "v");
S *object_3 = nullptr;
S *object_4 = new S("s", "b");
static S object_5("_", "t");
object_3 = new S("c", "o");
static S object_6("o", "s");
{
S *object_7 = new S("n", "l");
}
S *object_8 = nullptr;
{
S *object_9 = nullptr;
}
}

Answer (8):

__ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 34

Puzzle 48

void run() {
S *object_1 = new S("N", "x");
{
S *object_2 = nullptr;
{
S *object_3 = nullptr;
S *object_4 = new S("u", "u");
static S object_5("m", "e");
}
static S object_6("e", "p");
}
{
S *object_7 = new S("r", "T");
S *object_8 = nullptr;
{
object_8 = new S("i", "e");
static S object_9("c", "y");
}
delete object_7;
S *object_10 = nullptr;
}
}

Answer (11):

__ __ __ __ __ __ __ __ __ __ __

Puzzle 49

void run() {
S *object_1 = nullptr;
S object_2("l", "l");
object_1 = new S("o", "g");
delete object_1;
{
}
S *object_3 = nullptr;
object_3 = new S("n", "r");
S object_4("o", "a");
delete object_3;
S *object_5 = new S("m", "k");
Dynamic Lifetime Puzzles 35

Answer (9):

__ __ __ __ __ __ __ __ __

Puzzle 50

void run() {
{
}
static S object_1("u", "g");
S object_2("3", "r");
S *object_3 = nullptr;
static S object_4("2", "n");
object_3 = new S("s", "y");
static S object_5("t", "i");
}

Answer (9):

__ __ __ __ __ __ __ __ __

Puzzle 51

void run() {
S object_1("i", "t");
S object_2("n", "p");
static S object_3("o", "t");
S *object_4 = new S("u", "y");
static S object_5("t", "_");
{
static S object_6("_", "r");
}
}

Answer (11):

__ __ __ __ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 36

Puzzle 52

void run() {
static S object_1("s", "f");
S object_2("y", "b");
S *object_3 = nullptr;
S *object_4 = nullptr;
{
static S object_5("n", "u");
S *object_6 = new S("c", "n");
}
}

Answer (7):

__ __ __ __ __ __ __

Puzzle 53

void run() {
static S object_1("s", "l");
S *object_2 = new S("q", "r");
S *object_3 = nullptr;
delete object_2;
S *object_4 = nullptr;
{
S *object_5 = new S("t", "c");
}
S *object_6 = nullptr;
}

Answer (5):

__ __ __ __ __
Dynamic Lifetime Puzzles 37

Puzzle 54
void run() {
static S object_1("c", "l");
S object_2("h", "i");
{
S object_3("r", "o");
{
S object_4("o", "n");
}
}
S *object_5 = nullptr;
object_5 = new S(":", "l");
S *object_6 = new S(":", "q");
S object_7("c", "e");
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 55
void run() {
static S object_1("s", "e");
S object_2("t", "z");
{
S *object_3 = nullptr;
object_3 = new S("r", "k");
}
S *object_4 = nullptr;
{
S *object_5 = new S("e", "o");
object_4 = new S("a", "m");
delete object_4;
S *object_6 = new S("s", "o");
}
S *object_7 = new S("i", "m");
}

Answer (10):

__ __ __ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 38

Puzzle 56

void run() {
{
{
static S object_1("o", "m");
S *object_2 = nullptr;
object_2 = new S("f", "n");
static S object_3("s", "a");
S *object_4 = nullptr;
}
S *object_5 = nullptr;
S object_6("t", "e");
S *object_7 = new S("r", "r");
}
}

Answer (8):

__ __ __ __ __ __ __ __

Puzzle 57

void run() {
static S object_1("r", "f");
{
S *object_2 = nullptr;
object_2 = new S("i", "i");
}
{
S *object_3 = new S("e", "m");
{
delete object_3;
S object_4("a", "e");
S *object_5 = new S("n", "n");
delete object_5;
S object_6("_", "z");
}
S object_7("t", "a");
S *object_8 = nullptr;
}
}
Dynamic Lifetime Puzzles 39

Answer (13):

__ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 58

void run() {
{
S *object_1 = new S("e", "o");
}
S object_2("q", "n");
{
S *object_3 = nullptr;
static S object_4("u", "e");
}
S *object_5 = new S("a", "l");
delete object_5;
S *object_6 = new S("_", "r");
static S object_7("r", "g");
{
S *object_8 = new S("a", "t");
}
}

Answer (11):

__ __ __ __ __ __ __ __ __ __ __

Puzzle 59

void run() {
{
S object_1("f", "e");
}
{
{
}
static S object_2("s", "d");
S object_3("e", "t");
S *object_4 = nullptr;
}
S *object_5 = nullptr;
S *object_6 = new S("r", "q");
Dynamic Lifetime Puzzles 40

S *object_7 = new S("o", "q");


S object_8("u", "n");
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 60

void run() {
S object_1("s", "f");
S *object_2 = nullptr;
static S object_3("e", "r");
{
object_2 = new S("n", "n");
static S object_4("t", "o");
S *object_5 = nullptr;
S *object_6 = new S("i", "y");
delete object_2;
S *object_7 = nullptr;
S object_8("e", "_");
S *object_9 = new S("l", "g");
}
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 61

void run() {
{
static S object_1("i", "l");
S *object_2 = nullptr;
{
object_2 = new S("s", "u");
S *object_3 = nullptr;
{
S *object_4 = new S("_", "m");
}
S object_5("f", "a");
Dynamic Lifetime Puzzles 41

delete object_2;
object_3 = new S("n", "v");
S *object_6 = new S("d", "y");
}
S *object_7 = new S("m", "e");
delete object_7;
static S object_8("n", "a");
}
S *object_9 = new S("t", "w");
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 62

void run() {
S *object_1 = nullptr;
{
S *object_2 = new S("a", "o");
static S object_3("l", "g");
S *object_4 = new S("l", "n");
{
object_1 = new S("o", "l");
S object_5("c", "a");
S *object_6 = new S("a", "v");
{
static S object_7("t", "r");
{
delete object_2;
}
S *object_8 = nullptr;
}
S object_9("r", "_");
}
}
}

Answer (13):

__ __ __ __ __ __ __ __ __ __ __ __ __
Dynamic Lifetime Puzzles 42

Puzzle 63

void run() {
{
S *object_1 = new S("d", "y");
static S object_2("e", "t");
S *object_3 = nullptr;
object_3 = new S("s", "w");
S *object_4 = nullptr;
S object_5("t", "r");
S *object_6 = nullptr;
}
{
S object_7("o", "a");
{
S *object_8 = nullptr;
S *object_9 = new S("y", "y");
{
S *object_10 = new S("_", "y");
}
}
}
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 64

void run() {
S object_1("i", "a");
S *object_2 = new S("o", "e");
{
S object_3("s", "_");
}
static S object_4("b", "s");
S object_5("a", "l");
S object_6("s", "f");
delete object_2;
S *object_7 = new S(":", "s");
static S object_8(":", "g");
S *object_9 = nullptr;
Dynamic Lifetime Puzzles 43

S *object_10 = nullptr;
}

Answer (15):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime
thread_local is very similar to static, with one very important difference: their lifetimes end
not when the program ends, but when the thread ends! If you don’t know what a thread is, don’t
worry about it. The important thing to know is that the thread ends before the program ends.

void run() {
{
thread_local S object_1("1", "2");
}
thread_local S object_2("3", "4");
}

When this code is run, this is what happens:

void run() {
{
thread_local S object_1("1", "2"); // 1
}
thread_local S object_2("3", "4"); // 3
}

// Thread Ends

// object_2's lifetime ends: 4


// object_1's lifetime ends: 2

// Program Ends

// Nothing to print here!

The output is:

1342

Keeping in mind what happens first is going to be very key to solving puzzles with both thread_-
local and static objects in them!

44
Thread Local Lifetime Puzzles
Puzzle 65

void run() {
thread_local S object_1("m", "4");
{
thread_local S object_2("t", "6");
}
thread_local S object_3("1", "_");
thread_local S object_4("9", "7");
thread_local S object_5("9", "3");
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 66

void run() {
{
thread_local S object_1("p", "g");
}
thread_local S object_2("m", "n");
thread_local S object_3("r", "i");
thread_local S object_4(":", "r");
thread_local S object_5(":", "t");
thread_local S object_6("w", "s");
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

45
Thread Local Lifetime Puzzles 46

Puzzle 67

void run() {
{
{
thread_local S object_1("c", "l");
}
thread_local S object_2("y", "n");
}
thread_local S object_3("l", "n");
thread_local S object_4("_", "a");
thread_local S object_5("n", "m");
thread_local S object_6("e", "u");
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 68

void run() {
{
thread_local S object_1("i", "t");
}
{
thread_local S object_2("o", "i");
}
thread_local S object_3("s", "n");
thread_local S object_4("_", "I");
thread_local S object_5("b", ":");
thread_local S object_6("a", ":");
thread_local S object_7("s", "e");
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 47

Puzzle 69

void run() {
{
thread_local S object_1("r", "w");
{
thread_local S object_2("a", "e");
{
thread_local S object_3("n", "i");
}
thread_local S object_4("g", "v");
}
thread_local S object_5("e", "_");
}
thread_local S object_6("s", "p");
thread_local S object_7(":", "i");
thread_local S object_8(":", "z");
}

Answer (16):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 70

void run() {
{
{
thread_local S object_1("n", "e");
}
{
thread_local S object_2("u", "m");
}
thread_local S object_3("m", "a");
}
thread_local S object_4("p", "n");
thread_local S object_5("u", "e");
thread_local S object_6("n", "u");
thread_local S object_7("c", "r");
thread_local S object_8("t", "t");
thread_local S object_9(":", ":");
}
Thread Local Lifetime Puzzles 48

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 71

void run() {
{
thread_local S object_1("i", "r");
}
thread_local S object_2("d", "o");
{
thread_local S object_3("e", "t");
{
thread_local S object_4("n", "a");
{
thread_local S object_5("t", "r");
}
thread_local S object_6("i", "e");
}
thread_local S object_7("t", "p");
}
thread_local S object_8("y", "o");
thread_local S object_9(":", ":");
}

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 72

void run() {
{
thread_local S object_1("r", "t");
}
{
thread_local S object_2("a", "l");
}
thread_local S object_3("n", "u");
{
thread_local S object_4("g", "s");
{
Thread Local Lifetime Puzzles 49

thread_local S object_5("e", "e");


}
thread_local S object_6("s", "r");
}
thread_local S object_7(":", "_");
thread_local S object_8(":", "n");
thread_local S object_9("i", "i");
thread_local S object_10("n", "_");
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 73

void run() {
{
static S object_1("a", "f");
}
static S object_2("t", "e");
static S object_3("o", "r");
thread_local S object_4("m", "c");
static S object_5("i", "_");
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 74

void run() {
{
thread_local S object_1("t", "t");
}
thread_local S object_2("x", "p");
static S object_3("_", "n");
thread_local S object_4("e", "e");
static S object_5("x", "o");
static S object_6("c", "i");
}
Thread Local Lifetime Puzzles 50

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 75

void run() {
thread_local S object_1("s", "i");
{
static S object_2("i", "t");
thread_local S object_3("g", "m");
static S object_4("_", "_");
{
thread_local S object_5("a", "o");
}
static S object_6("t", "c");
}
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 76

void run() {
thread_local S object_1("u", "t");
thread_local S object_2("n", "c");
{
static S object_3("a", "n");
thread_local S object_4("r", "n");
{
static S object_5("y", "o");
}
static S object_6("_", "i");
thread_local S object_7("f", "u");
}
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 51

Puzzle 77

void run() {
static S object_1("u", "e");
{
static S object_2("n", "c");
{
thread_local S object_3("w", "e");
}
thread_local S object_4("r", "f");
}
{
static S object_5("a", "n");
}
static S object_6("p", "e");
thread_local S object_7("_", "e");
static S object_8("r", "r");
}

Answer (16):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 78

void run() {
static S object_1("u", "y");
thread_local S object_2("n", "d");
static S object_3("i", "p");
{
static S object_4("n", "o");
thread_local S object_5("i", "e");
}
{
static S object_6("t", "c");
thread_local S object_7("i", "z");
}
{
static S object_8("a", "_");
thread_local S object_9("l", "i");
}
}
Thread Local Lifetime Puzzles 52

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 79

void run() {
{
{
static S object_1("o", "e");
{
thread_local S object_2("s", "f");
}
static S object_3("t", "z");
{
static S object_4("r", "e");
}
static S object_5("s", "e");
}
thread_local S object_6("t", ":");
static S object_7("r", "r");
thread_local S object_8("e", ":");
}
thread_local S object_9("a", "m");
}

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 80

void run() {
static S object_1("t", "h");
{
thread_local S object_2("o", "_");
static S object_3("t", "t");
thread_local S object_4("a", "d");
}
{
static S object_5("l", "i");
{
thread_local S object_6("l", "e");
Thread Local Lifetime Puzzles 53

{
thread_local S object_7("y", "r");
}
static S object_8("_", "w");
}
thread_local S object_9("o", "e");
}
thread_local S object_10("r", "d");
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 81

void run() {
thread_local S object_1("a", "k");
thread_local S object_2("d", "c");
thread_local S object_3("o", "o");
{
S object_4("p", "t");
}
thread_local S object_5("_", "l");
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 82

void run() {
S object_1("r", "j");
thread_local S object_2("a", "n");
{
S object_3("n", "g");
}
S object_4("e", ":");
thread_local S object_5("s", "i");
thread_local S object_6(":", "o");
}
Thread Local Lifetime Puzzles 54

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 83

void run() {
thread_local S object_1("c", "8");
thread_local S object_2("o", "f");
{
S object_3("d", "c");
thread_local S object_4("e", "t");
}
S object_5("v", "_");
{
thread_local S object_6("t", "u");
}
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 84

void run() {
S object_1("s", "b");
{
S object_2("t", "o");
}
{
thread_local S object_3("p", "s");
}
thread_local S object_4("_", "k");
thread_local S object_5("c", "c");
thread_local S object_6("a", "a");
S object_7("l", "l");
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 55

Puzzle 85

void run() {
{
S object_1("r", "e");
{
thread_local S object_2("a", "d");
}
S object_3("n", "g");
}
{
thread_local S object_4("s", "n");
S object_5(":", ":");
}
S object_6("f", "_");
S object_7("i", "d");
thread_local S object_8("n", "e");
}

Answer (16):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 86

void run() {
{
S object_1("r", "n");
thread_local S object_2("a", "n");
{
S object_3("n", "g");
}
thread_local S object_4("e", "_");
S object_5("s", "e");
{
S object_6(":", ":");
}
thread_local S object_7("g", "e");
}
thread_local S object_8("e", "t");
S object_9("r", "a");
}
Thread Local Lifetime Puzzles 56

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 87

void run() {
{
{
thread_local S object_1("i", "m");
{
S object_2("s", "o");
{
S object_3("_", "e");
}
S object_4("r", "r");
}
S object_5("r", "_");
}
S object_6("c", "o");
}
thread_local S object_7("d", "u");
S object_8("e", "e");
thread_local S object_9("_", "n");
}

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 88

void run() {
{
{
thread_local S object_1("t", "e");
S object_2("h", "a");
thread_local S object_3("r", "l");
S object_4("e", "p");
{
S object_5("e", "w");
thread_local S object_6("_", "b");
}
Thread Local Lifetime Puzzles 57

thread_local S object_7("a", "a");


{
thread_local S object_8("y", "r");
S object_9("_", "c");
}
S object_10("o", "m");
}
}
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 89

void run() {
S *object_1 = new S("a", "r");
{
S *object_2 = new S("c", "v");
}
thread_local S object_3("o", "h");
S *object_4 = nullptr;
S *object_5 = new S("s", "e");
}

Answer (5):

__ __ __ __ __

Puzzle 90

void run() {
{
}
S *object_1 = nullptr;
object_1 = new S("e", "x");
delete object_1;
S *object_2 = new S("p", "i");
S *object_3 = new S("l", "k");
delete object_2;
thread_local S object_4("c", "t");
S *object_5 = nullptr;
Thread Local Lifetime Puzzles 58

S *object_6 = new S("i", "a");


}

Answer (8):

__ __ __ __ __ __ __ __

Puzzle 91

void run() {
S *object_1 = nullptr;
thread_local S object_2("p", "n");
{
object_1 = new S("a", "r");
delete object_1;
{
S *object_3 = nullptr;
S *object_4 = new S("t", "y");
object_3 = new S("i", "a");
}
S *object_5 = new S("t", "b");
}
thread_local S object_6("i", "o");
}

Answer (9):

__ __ __ __ __ __ __ __ __

Puzzle 92

void run() {
thread_local S object_1("m", "t");
S *object_2 = new S("i", "d");
delete object_2;
{
thread_local S object_3("p", "n");
{
S *object_4 = nullptr;
S *object_5 = new S("o", "d");
S *object_6 = nullptr;
}
S *object_7 = new S("i", "f");
Thread Local Lifetime Puzzles 59

}
}

Answer (8):

__ __ __ __ __ __ __ __

Puzzle 93

void run() {
{
S *object_1 = nullptr;
{
S *object_2 = new S("r", "a");
S *object_3 = nullptr;
delete object_2;
thread_local S object_4("n", "d");
}
thread_local S object_5("g", "n");
{
}
object_1 = new S("e", "s");
thread_local S object_6("s", "e");
}
S *object_7 = new S(":", "p");
thread_local S object_8(":", "r");
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 94

void run() {
{
{
S *object_1 = nullptr;
S *object_2 = new S("m", "h");
object_1 = new S("o", "h");
}
S *object_3 = new S("v", "e");
{
Thread Local Lifetime Puzzles 60

delete object_3;
S *object_4 = new S("_", "q");
}
}
thread_local S object_5("s", "l");
S *object_6 = nullptr;
S *object_7 = new S("e", "n");
delete object_7;
object_6 = new S("t", "i");
S *object_8 = nullptr;
delete object_6;
thread_local S object_9("n", "e");
}

Answer (13):

__ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 95

void run() {
S *object_1 = nullptr;
{
thread_local S object_2("c", "d");
{
S *object_3 = new S("h", "k");
thread_local S object_4("r", "n");
{
S *object_5 = new S("o", "r");
object_1 = new S("n", "n");
}
thread_local S object_6("o", "u");
thread_local S object_7(":", "o");
S *object_8 = nullptr;
thread_local S object_9(":", "r");
}
}
}

Answer (13):

__ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 61

Puzzle 96

void run() {
{
thread_local S object_1("s", "e");
}
{
}
{
}
S *object_2 = new S("h", "u");
{
delete object_2;
}
thread_local S object_3("f", "n");
S *object_4 = new S("f", "e");
thread_local S object_5("l", "i");
delete object_4;
S *object_6 = new S("_", "o");
delete object_6;
S *object_7 = new S("r", "r");
thread_local S object_8("d", "g");
S *object_9 = nullptr;
object_9 = new S("e", "_");
delete object_7;
delete object_9;
thread_local S object_10("e", "n");
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 97

void run() {
thread_local S object_1("a", "h");
S *object_2 = nullptr;
S *object_3 = new S("s", "i");
delete object_3;
S *object_4 = new S("n", "p");
S *object_5 = nullptr;
}
Thread Local Lifetime Puzzles 62

Answer (5):

__ __ __ __ __

Puzzle 98
void run() {
{
S object_1("m", "n");
thread_local S object_2("o", "t");
S *object_3 = nullptr;
thread_local S object_4("n", "c");
object_3 = new S("e", "y");
S *object_5 = nullptr;
delete object_3;
S object_6("p", "u");
}
}

Answer (10):

__ __ __ __ __ __ __ __ __ __

Puzzle 99
void run() {
S *object_1 = new S("u", "n");
delete object_1;
S *object_2 = new S("i", "e");
S object_3("q", "o");
{
S *object_4 = nullptr;
thread_local S object_5("u", "k");
delete object_2;
object_4 = new S("_", "l");
thread_local S object_6("l", "c");
}
}

Answer (11):

__ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 63

Puzzle 100
void run() {
S *object_1 = nullptr;
S *object_2 = new S("s", "r");
{
object_1 = new S("t", "a");
S *object_3 = new S("r", "d");
{
S object_4("t", "o");
}
S *object_5 = new S("u", "n");
S *object_6 = nullptr;
S object_7("l", "l");
}
}

Answer (8):

__ __ __ __ __ __ __ __

Puzzle 101
void run() {
S object_1("i", "w");
{
thread_local S object_2("o", "d");
S object_3("s", "i");
{
S object_4("_", ":");
thread_local S object_5("b", "r");
{
S object_6("a", "s");
}
S *object_7 = new S("e", "p");
}
thread_local S object_8(":", "o");
}
}

Answer (15):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 64

Puzzle 102

void run() {
thread_local S object_1("a", "e");
S *object_2 = nullptr;
object_2 = new S("s", "l");
{
thread_local S object_3("s", "r");
S *object_4 = new S("o", "e");
S object_5("c", "n");
{
thread_local S object_6("_", "d");
}
delete object_2;
S *object_7 = new S("e", "s");
{
S object_8("g", "e");
S *object_9 = nullptr;
}
}
}

Answer (14):

__ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 103

void run() {
thread_local S object_1("s", "m");
{
thread_local S object_2("t", "a");
S *object_3 = new S("r", "e");
}
thread_local S object_4("i", "e");
S *object_5 = new S("n", "c");
S *object_6 = nullptr;
S *object_7 = new S("g", "i");
S object_8("s", "r");
S *object_9 = new S("t", "x");
}

Answer (12):
Thread Local Lifetime Puzzles 65

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 104

void run() {
S *object_1 = nullptr;
S *object_2 = nullptr;
{
}
thread_local S object_3("s", "l");
S object_4("p", "a");
{
S *object_5 = new S("h", "j");
}
object_1 = new S("_", "n");
{
S *object_6 = nullptr;
thread_local S object_7("n", "n");
{
S *object_8 = nullptr;
thread_local S object_9("e", "n");
S object_10("u", "m");
}
}
}

Answer (12):

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 105

void run() {
S *object_1 = nullptr;
S *object_2 = new S("s", "h");
{
S *object_3 = nullptr;
thread_local S object_4("p", "f");
}
delete object_2;
S *object_5 = new S("_", "o");
S("l", "e");
Thread Local Lifetime Puzzles 66

S *object_7 = nullptr;
S object_8("g", "r");
{
object_1 = new S("e", "d");
new S("n", "u");
{
thread_local S object_10("d", "e");
}
}
}

Answer (13):

__ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 106

void run() {
delete new S("p", "m");
S *object_2 = new S("r", ":");
delete object_2;
S(":", "u");
S *object_4 = new S("n", "l");
delete new S("s", "y");
thread_local S object_6("n", "d");
S("c", "h");
thread_local S object_8("r", "e");
{
S *object_9 = nullptr;
}
S object_10("o", "i");
thread_local S object_11("n", "z");
}

Answer (19):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 67

Puzzle 107

void run() {
S object_1("m", "l");
static S object_2("e", "d");
S object_3("m", "e");
S("o", "r");
static S object_5("y", "e");
S *object_6 = new S("_", "r");
{
S *object_7 = nullptr;
thread_local S object_8("o", "a");
{
S object_9("r", "d");
}
S object_10("e", "r");
delete object_6;
static S object_11("_", "x");
}
}

Answer (20):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 108

void run() {
{
thread_local S object_1("o", "a");
S *object_2 = nullptr;
{
}
thread_local S object_3("u", "h");
S *object_4 = nullptr;
object_2 = new S("t", "o");
S *object_5 = new S("_", "e");
{
delete object_2;
S object_6("f", "w");
{
new S("_", "i");
{
Thread Local Lifetime Puzzles 68

S object_8("r", "a");
}
S object_9("n", ":");
S *object_10 = nullptr;
static S object_11("g", "t");
delete object_5;
object_4 = new S(":", "t");
S *object_12 = nullptr;
}
}
}
}

Answer (18):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 109

void run() {
S object_1("r", ":");
S("a", "n");
S object_3("g", ":");
S("e", "s");
thread_local S object_5(":", "t");
S *object_6 = nullptr;
S object_7(":", "w");
{
thread_local S object_8("r", "p");
S("e", "f");
}
thread_local S object_10("_", "m");
object_6 = new S("v", "r");
static S object_11("i", "y");
S *object_12 = nullptr;
thread_local S object_13("e", "e");
}

Answer (23):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 69

Puzzle 110

void run() {
{
thread_local S object_1("u", "a");
S object_2("n", "p");
static S object_3("d", "r");
{
S *object_4 = nullptr;
delete new S("e", "r");
{
object_4 = new S("f", "p");
{
S *object_6 = new S("l", "r");
static S object_7("o", "o");
S("w", "_");
S *object_9 = new S("e", "y");
thread_local S object_10("r", "r");
delete object_6;
{
S *object_11 = new S("o", "y");
S("r", ":");
static S object_13(":", "t");
thread_local S object_14("o", "e");
}
}
}
}
}
}

Answer (25):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 70

Puzzle 111

void run() {
{
S *object_1 = new S("w", "f");
thread_local S object_2("e", "t");
{
S *object_3 = nullptr;
static S object_4("a", "r");
thread_local S object_5("k", "a");
S *object_6 = new S("_", "n");
{
object_3 = new S("o", "d");
{
static S object_7("r", "e");
delete object_3;
S *object_8 = new S("e", "x");
S object_9("r", "r");
{
S *object_10 = new S("i", "d");
delete object_6;
{
S *object_11 = new S("g", "u");
}
new S(":", "g");
thread_local S object_13(":", "e");
S *object_14 = new S("g", "x");
}
}
}
}
}
}

Answer (22):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 71

Puzzle 112

void run() {
S object_1("a", "p");
{
S *object_2 = nullptr;
}
{
thread_local S object_3("t", "c");
S object_4("o", "i");
thread_local S object_5("m", "i");
}
static S object_6("c", "t");
S *object_7 = nullptr;
S *object_8 = new S("_", "a");
thread_local S object_9("f", "l");
object_7 = new S("e", "_");
delete new S("t", "c");
S object_11("h", "x");
S *object_12 = new S("_", "i");
{
delete object_8;
S("d", "d");
delete object_7;
{
static S object_14("e", "i");
S *object_15 = nullptr;
}
}
}

Answer (25):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 72

Puzzle 113

void run() {
delete new S("r", "e");
S *object_2 = nullptr;
object_2 = new S("g", "i");
S("e", "x");
{
static S object_4("_", "e");
S object_5("t", "s");
{
new S("r", "q");
S *object_7 = new S("a", "h");
}
delete object_2;
thread_local S object_8("t", "e");
}
static S object_9(":", "m");
{
thread_local S object_10(":", "t");
{
static S object_11("l", "a");
}
S object_12("o", "a");
{
S object_13("o", "l");
{
S *object_14 = nullptr;
}
S *object_15 = new S("k", "p");
S object_16("u", "l");
delete object_15;
{
S *object_17 = new S("_", "c");
delete object_17;
static S object_18("o", "n");
}
}
}
}

Answer (32):
Thread Local Lifetime Puzzles 73

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __

Puzzle 114

void run() {
static S object_1("r", "l");
S *object_2 = nullptr;
{
object_2 = new S("a", "n");
delete object_2;
S *object_3 = new S("g", "t");
static S object_4("e", "e");
{
S *object_5 = nullptr;
}
new S("s", "h");
thread_local S object_7(":", "i");
{
S *object_8 = new S(":", "l");
delete object_3;
}
S *object_9 = new S("a", "e");
S *object_10 = nullptr;
thread_local S object_11("k", "t");
delete object_9;
S object_12("_", "e");
S("v", "i");
}
S *object_14 = nullptr;
thread_local S object_15("w", "n");
static S object_16(":", "n");
S *object_17 = new S(":", "c");
{
S *object_18 = new S("s", "k");
object_14 = new S("e", "v");
S *object_19 = nullptr;
}
}

Answer (27):
Thread Local Lifetime Puzzles 74

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__

Puzzle 115

void run() {
S *object_1 = new S("r", "a");
delete object_1;
static S object_2("n", "e");
thread_local S object_3("g", "n");
S *object_4 = nullptr;
delete new S("e", "s");
S *object_6 = nullptr;
thread_local S object_7(":", "e");
delete new S(":", "s");
S object_9("e", "d");
thread_local S object_10("t", "r");
static S object_11("_", "c");
{
thread_local S object_12("s", "e");
}
{
S *object_13 = nullptr;
S object_14("y", "m");
}
{
thread_local S object_15("m", "f");
S *object_16 = nullptr;
}
S *object_17 = new S("e", "c");
thread_local S object_18("t", "f");
S("r", "i");
delete object_17;
thread_local S object_20("_", "i");
}

Answer (32):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __
Thread Local Lifetime Puzzles 75

Puzzle 116

void run() {
S object_1("p", "_");
{
thread_local S object_2("m", "c");
{
static S object_3("r", "e");
S object_4(":", ":");
S *object_5 = nullptr;
}
S *object_6 = nullptr;
thread_local S object_7("m", "o");
{
S *object_8 = new S("e", "r");
static S object_9("m", "t");
new S("o", "i");
delete object_8;
new S("y", "a");
{
thread_local S object_12("_", "l");
S("r", "e");
{
thread_local S object_14("s", "l");
object_6 = new S("o", "r");
static S object_15("u", "a");
delete object_6;
S object_16("c", "o");
thread_local S object_17("e", "a");
{
S *object_18 = nullptr;
S *object_19 = new S(":", "r");
}
S(":", "d");
}
}
}
}
}

Answer (33):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 76

__ __ __ __ __ __ __

Puzzle 117
void run() {
thread_local S object_1("r", "e");
thread_local S object_2("a", "r");
{
S("n", "g");
thread_local S object_4("e", "_");
S *object_5 = new S("s", ":");
delete object_5;
static S object_6(":", "t");
S object_7("u", "_");
delete new S("n", "i");
S *object_9 = nullptr;
static S object_10("n", "l");
{
S("i", "t");
new S("i", "e");
{
static S object_13("a", "u");
}
static S object_14("l", "s");
delete new S("i", "z");
{
thread_local S object_16("e", "n");
delete new S("d", "_");
S object_18("c", "y");
S *object_19 = new S("o", "i");
new S("p", "o");
S *object_21 = nullptr;
}
}
}
}

Answer (35):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 77

Puzzle 118

void run() {
{
S *object_1 = nullptr;
{
object_1 = new S("t", " ");
{
S *object_2 = new S("y", "x");
{
thread_local S object_3("p", "a");
{
thread_local S object_4("e", "r");
{
delete object_1;
static S object_5("o", "r");
thread_local S object_6("f", "e");
}
S *object_7 = nullptr;
S *object_8 = new S(" ", "p");
object_7 = new S("u", "o");
thread_local S object_9("n", "t");
delete object_7;
{
S *object_10 = nullptr;
delete new S("r", "d");
S object_12("e", "n");
static S object_13("r", "o");
object_10 = new S("e", "j");
thread_local S object_14("d", "i");
S *object_15 = new S("_", "v");
static S object_16("m", "t");
{
{
thread_local S object_17("a", "_");
{
delete object_8;
}
S object_18(":", "o");
thread_local S object_19(":", "t");
S *object_20 = nullptr;
thread_local S object_21("c", "s");
}
Thread Local Lifetime Puzzles 78

S *object_22 = nullptr;
}
}
}
}
}
}
}
}

Answer (37):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __

Puzzle 119

void run() {
new S("r", "n");
{
S *object_2 = nullptr;
object_2 = new S("a", "v");
S *object_3 = new S("n", ":");
{
thread_local S object_4("g", "u");
S object_5("e", "e");
{
{
S *object_6 = new S("s", "m");
delete object_3;
{
new S(":", "u");
S *object_8 = nullptr;
new S("u", "n");
S object_10("n", "i");
static S object_11("i", "t");
S *object_12 = new S("n", "v");
}
static S object_13("t", "l");
{
S *object_14 = new S("i", "p");
S object_15("a", "l");
Thread Local Lifetime Puzzles 79

}
S *object_16 = nullptr;
S object_17("i", "r");
object_16 = new S("z", "n");
S *object_18 = new S("e", "j");
delete new S("d", "_");
delete object_6;
{
S *object_20 = new S("o", "k");
S object_21("v", "_");
S *object_22 = nullptr;
thread_local S object_23("e", "s");
}
}
}
}
}
}

Answer (33):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __

Puzzle 120

void run() {
S *object_1 = new S("b", "p");
static S object_2("a", "d");
S *object_3 = new S("s", "r");
static S object_4("i", "i");
S *object_5 = new S("c", "p");
{
S *object_6 = new S("_", "m");
}
{
delete new S("f", "o");
}
delete object_3;
S *object_8 = nullptr;
new S("m", "d");
S("a", "t");
Thread Local Lifetime Puzzles 80

S object_11("_", "x");
{
thread_local S object_12("p", "g");
}
object_8 = new S("a", "k");
thread_local S object_13("r", "r");
S object_14("s", "e");
thread_local S object_15("e", "a");
S object_16("_", "n");
thread_local S object_17("c", "_");
static S object_18("o", "_");
{
S *object_19 = new S("n", "r");
}
thread_local S object_20("t", "t");
{
S object_21("e", "t");
new S("x", "e");
S *object_23 = nullptr;
}
S object_24(":", ":");
}

Answer (39):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 121

void run() {
{
static S object_1("c", "e");
S *object_2 = new S("o", "i");
static S object_3("n", "n");
S *object_4 = new S("d", "e");
{
new S("i", "h");
S object_6("t", "n");
delete object_2;
S *object_7 = new S("o", "r");
}
Thread Local Lifetime Puzzles 81

}
static S object_8("_", "o");
S object_9("v", "n");
static S object_10("a", "_");
thread_local S object_11("r", "i");
{
}
new S("i", "p");
static S object_13("a", "y");
{
S *object_14 = new S("b", "f");
}
thread_local S object_15("l", "t");
{
S *object_16 = nullptr;
S *object_17 = new S("e", "d");
}
static S object_18("_", "f");
{
thread_local S object_19("a", "o");
S *object_20 = nullptr;
new S("n", "m");
}
S object_22("y", ":");
new S(":", "s");
S *object_24 = nullptr;
}

Answer (34):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 82

Puzzle 122

void run() {
S *object_1 = new S("e", "u");
thread_local S object_2("x", "l");
S object_3("e", "e");
static S object_4("c", "y");
S *object_5 = nullptr;
{
delete object_1;
object_5 = new S("t", "p");
S *object_6 = nullptr;
}
static S object_7("i", "c");
S *object_8 = new S("o", "g");
S object_9("n", "c");
{
S *object_10 = nullptr;
static S object_11(":", "i");
{
S object_12(":", "n");
delete object_5;
object_10 = new S("a", "o");
S("r", "a");
{
S *object_14 = new S("l", "v");
thread_local S object_15("l", "o");
S *object_16 = nullptr;
S object_17("e", "l");
}
{
S object_18("_", "n");
S *object_19 = new S("u", "e");
}
{
thread_local S object_20("s", "p");
{
thread_local S object_21("e", "_");
}
S *object_22 = nullptr;
S object_23("q", "e");
thread_local S object_24("u", "d");
S *object_25 = nullptr;
Thread Local Lifetime Puzzles 83

}
}
}
}

Answer (38):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 123

void run() {
S *object_1 = nullptr;
object_1 = new S("w", "b");
S object_2("h", "t");
S("e", "t");
S *object_4 = new S("h", "a");
S *object_5 = nullptr;
S *object_6 = nullptr;
{
S *object_7 = nullptr;
S *object_8 = new S("e", "g");
}
thread_local S object_9("r", " ");
S *object_10 = new S(" ", "w");
S("r", "a");
static S object_12("n", "e");
new S("d", "t");
object_5 = new S(" ", "t");
S object_14("m", "a");
{
S *object_15 = nullptr;
delete object_4;
S *object_16 = new S("y", "e");
S object_17(" ", "i");
}
S *object_18 = nullptr;
thread_local S object_19("n", "a");
S *object_20 = new S("t", "r");
static S object_21("r", "c");
object_6 = new S("o", "b");
Thread Local Lifetime Puzzles 84

static S object_22("d", "a");


object_18 = new S("u", "r");
static S object_23("c", "r");
delete new S("e", " ");
S object_25("a", "d");
S *object_26 = new S(" ", "u");
}

Answer (38):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __ __

Puzzle 124

void run() {
thread_local S object_1("t", "r");
S object_2("y", "i");
static S object_3("p", "r");
delete new S("e", " ");
{
delete new S("o", "f");
{
S *object_6 = nullptr;
S object_7(" ", "e");
{
S *object_8 = new S("u", "x");
}
S *object_9 = nullptr;
S *object_10 = new S("n", "b");
static S object_11("o", "o");
S object_12("r", "r");
object_6 = new S("d", "e");
delete object_6;
}
S *object_13 = new S("d", "_");
{
delete object_13;
S *object_14 = nullptr;
static S object_15("s", "t");
S *object_16 = new S("e", "m");
}
Thread Local Lifetime Puzzles 85

S *object_17 = nullptr;
{
S *object_18 = nullptr;
}
object_17 = new S("t", "l");
{
static S object_19(":", "a");
thread_local S object_20(":", "e");
S object_21("c", "l");
delete new S("o", "n");
{
S("s", "t");
S *object_24 = nullptr;
S object_25("_", "o");
delete object_17;
}
S object_26("c", "a");
}
{
thread_local S object_27("_", "t");
}
}
}

Answer (43):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 125

void run() {
S *object_1 = nullptr;
S *object_2 = nullptr;
static S object_3("i", "v");
S("s", "_");
S object_5("t", "t");
S *object_6 = nullptr;
object_2 = new S("r", "i");
delete object_2;
S *object_7 = nullptr;
thread_local S object_8("v", "e");
Thread Local Lifetime Puzzles 86

S object_9("i", "c");
S("a", "l");
S object_11("l", "u");
S *object_12 = nullptr;
object_6 = new S("y", "u");
{
S *object_13 = nullptr;
}
S("_", "d");
S *object_15 = nullptr;
S *object_16 = nullptr;
thread_local S object_17("e", "l");
thread_local S object_18("f", "b");
S *object_19 = nullptr;
S object_20("a", "r");
{
delete object_6;
S *object_21 = new S("l", "n");
static S object_22("t", "_");
{
S *object_23 = nullptr;
}
S object_24("_", "t");
{
S *object_25 = nullptr;
thread_local S object_26("c", "i");
S *object_27 = new S("o", "h");
delete object_21;
}
{
S *object_28 = new S("s", "e");
}
}
}

Answer (36):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 87

Puzzle 126

void run() {
{
static S object_1("h", "s");
}
delete new S("o", "w");
new S(" ", "o");
S object_4("r", "a");
new S("a", "c");
S *object_6 = nullptr;
{
S object_7("n", "m");
static S object_8("d", "e");
S *object_9 = new S("o", "x");
}
{
static S object_10("_", "u");
object_6 = new S("d", "o");
}
S object_11("e", "r");
static S object_12("v", "l");
delete new S("i", "c");
S object_14("e", "e");
S *object_15 = nullptr;
static S object_16(":", "a");
{
thread_local S object_17(":", "e");
{
delete object_6;
S *object_18 = new S("p", "e");
object_15 = new S("e", "h");
S *object_19 = new S("r", "b");
thread_local S object_20("a", "t");
S("t", "o");
{
static S object_22("r", "v");
S *object_23 = nullptr;
static S object_24("(", " ");
S *object_25 = new S(")", "d");
}
{
S *object_26 = new S(" ", "x");
Thread Local Lifetime Puzzles 88

static S object_27("g", "s");


delete object_18;
new S("n", "c");
}
}
}
}

Answer (46):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

Puzzle 127

void run() {
{
static S object_1("a", "t");
S *object_2 = nullptr;
S *object_3 = new S("l", "j");
S object_4("l", "o");
}
{
S *object_5 = new S("c", "o");
{
static S object_6("a", "c");
S object_7("t", " ");
static S object_8("i", "e");
delete object_5;
{
static S object_9("n", "j");
S *object_10 = new S(" ", "t");
{
S object_11("o", "a");
{
static S object_12("f", "b");
S *object_13 = nullptr;
S *object_14 = new S(" ", "s");
thread_local S object_15("b", " ");
static S object_16("i", "o");
S *object_17 = nullptr;
delete object_10;
Thread Local Lifetime Puzzles 89

{
thread_local S object_18("-", "s");
{
S *object_19 = nullptr;
thread_local S object_20("f", "s");
delete new S("i", "e");
object_17 = new S("l", "m");
new S("d", "c");
}
S *object_23 = nullptr;
delete object_14;
thread_local S object_24(" ", "a");
{
S object_25("w", " ");
thread_local S object_26("i", "l");
S("t", "h");
thread_local S object_28("i", "c");
S *object_29 = new S("n", "y");
}
}
}
}
}
}
}
}

Answer (46):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Thread Local Lifetime Puzzles 90

Puzzle 128

void run() {
static S object_1("r", "t");
S object_2("a", "o");
{
S *object_3 = new S("n", "b");
S *object_4 = nullptr;
static S object_5("g", "l");
}
{
S *object_6 = nullptr;
{
S("e", "s");
}
{
S *object_8 = nullptr;
}
object_6 = new S(":", "i");
S *object_9 = nullptr;
S *object_10 = new S(":", "o");
delete object_6;
{
object_9 = new S("n", "l");
static S object_11("_", "u");
{
S *object_12 = new S("f", "a");
delete object_10;
delete new S("u", "n");
}
S object_14("d", "_");
static S object_15("_", "s");
S *object_16 = new S("r", ":");
thread_local S object_17("e", "_");
static S object_18("s", "e");
thread_local S object_19("u", "d");
delete object_9;
thread_local S object_20("t", "n");
S *object_21 = new S(":", "n");
delete object_16;
delete new S("o", "p");
S("e", "r");
static S object_24("a", "r");
Thread Local Lifetime Puzzles 91

S *object_25 = nullptr;
object_25 = new S("t", "l");
S *object_26 = nullptr;
S object_27("o", "r");
}
{
S *object_28 = new S("i", "x");
delete new S("n", "_");
}
thread_local S object_30("f", "u");
}
}

Answer (49):

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
Solutions
Solution 1

void run() {
S object_1("p", "s"); // p
S object_2("l", "u"); // l
} // u
// s

// Answer: plus

Solution 2

void run() {
{
S object_1("s", "l"); // s
{
S object_2("t", "r"); // t
} // r
S object_3("t", "o"); // t
} // o
// l
}

// Answer: strtol

Solution 3

void run() {
{
{
S object_1("p", "a"); // p
} // a
S object_2("c", "k"); // c
} // k
S object_3("a", "d"); // a
S object_4("g", "e"); // g
} // e
// d

92
Solutions 93

// Answer: packaged

Solution 4

void run() {
{
S object_1("w", "e"); // w
} // e
{
S object_2("a", "k"); // a
} // k
{
S object_3("_", "o"); // _
} // o
S object_4("r", "r"); // r
S object_5("d", "e"); // d
} // e
// r

// Answer: weak_order

Solution 5

void run() {
{
{
S object_1("i", "r"); // i
{
S object_2("s", "_"); // s
} // _
S object_3("p", "a"); // p
} // a
// r
S object_4("t", "i"); // t
} // i
S object_5("t", "d"); // t
S object_6("i", "e"); // i
S object_7("o", "n"); // o
} // n
// e
// d
Solutions 94

// Answer: is_partitioned

Solution 6

void run() {
{
S object_1("s", "u"); // s
{
S object_2("e", "_"); // e
{
S object_3("t", "w"); // t
{
S object_4(":", ":"); // :
} // :
S object_5("l", "o"); // l
} // o
// w
S object_6("e", "r"); // e
} // r
// _
S object_7("b", "o"); // b
} // o
// u
S object_8("n", "d"); // n
} // d

// Answer: set::lower_bound

Solution 7

void run() {
{
S object_1("e", "q"); // e
} // q
{
S object_2("u", "a"); // u
} // a
{
S object_3("l", "_"); // l
} // _
{
S object_4("t", "o"); // t
Solutions 95

} // o
S object_5(":", "r"); // :
S object_6(":", "o"); // :
S object_7("o", "t"); // o
S object_8("p", "a"); // p
S object_9("e", "r"); // e
} // r
// a
// t
// o
// r

// Answer: equal_to::operator

Solution 8

void run() {
S object_1("w", "e"); // w
S object_2("e", "l"); // e
{
S object_3("a", "k"); // a
} // k
S object_4("l", "b"); // l
{
S object_5("y", "_"); // y
} // _
{
S object_6("i", "n"); // i
} // n
S object_7("c", "a"); // c
{
S object_8("r", "t"); // r
{
S object_9("e", "m"); // e
} // m
S object_10("e", "n"); // e
} // n
// t
} // a
// b
// l
// e
Solutions 96

// Answer: weakly_incrementable

Solution 9

void run() {
static S object_1("f", "s"); // f
{
static S object_2("g", "w"); // g
}
static S object_3("e", "t"); // e
}

// Program Exit
// t
// w
// s

// Answer: fgetws

Solution 10

void run() {
{
static S object_1("d", "e"); // d
}
static S object_2("i", "t"); // i
static S object_3("s", "e"); // s
static S object_4("c", "r"); // c
}

// Program Exit
// r
// e
// t
// e

// Answer: discrete
Solutions 97

Solution 11

void run() {
static S object_1("u", "d"); // u
{
static S object_2("n", "e"); // n
{
static S object_3("e", "t"); // e
}
static S object_4("x", "c"); // x
}
static S object_5("p", "e"); // p
}

// Program Exit
// e
// c
// t
// e
// d

// Answer: unexpected

Solution 12

void run() {
{
static S object_1("m", "t"); // m
{
static S object_2("a", "c"); // a
}
static S object_3("p", "a"); // p
}
static S object_4(":", "r"); // :
static S object_5(":", "t"); // :
static S object_6("e", "x"); // e
}

// Program Exit
// x
// t
// r
// a
Solutions 98

// c
// t

// Answer: map::extract

Solution 13

void run() {
{
static S object_1("U", "t"); // U
{
static S object_2("n", "i"); // n
}
static S object_3("a", "a"); // a
{
static S object_4("r", "r"); // r
}
static S object_5("y", "T"); // y
}
static S object_6("T", "e"); // T
static S object_7("y", "p"); // y
}

// Program Exit
// p
// e
// T
// r
// a
// i
// t

// Answer: UnaryTypeTrait
Solutions 99

Solution 14

void run() {
{
{
static S object_1("p", "N"); // p
}
{
static S object_2("l", "_"); // l
}
static S object_3("a", ":"); // a
}
static S object_4("c", ":"); // c
static S object_5("e", "s"); // e
static S object_6("h", "r"); // h
static S object_7("o", "e"); // o
static S object_8("l", "d"); // l
}

// Program Exit
// d
// e
// r
// s
// :
// :
// _
// N

// Answer: placeholders::_N

Solution 15

void run() {
{
static S object_1("i", "e"); // i
}
static S object_2("n", "p"); // n
{
static S object_3("t", "y"); // t
}
{
static S object_4("e", "t"); // e
Solutions 100

}
{
static S object_5("g", " "); // g
}
static S object_6("e", "s"); // e
static S object_7("r", "s"); // r
static S object_8("-", "a"); // -
static S object_9("c", "l"); // c
}

// Program Exit
// l
// a
// s
// s
//
// t
// y
// p
// e

// Answer: integer-class type

Solution 16

void run() {
static S object_1("i", "v"); // i
static S object_2("s", "_"); // s
{
static S object_3("_", "e"); // _
}
static S object_4("m", "l"); // m
{
static S object_5("o", "b"); // o
{
static S object_6("v", "a"); // v
{
static S object_7("e", "n"); // e
}
static S object_8("_", "g"); // _
}
static S object_9("a", "i"); // a
}
Solutions 101

static S object_10("s", "s"); // s


}

// Program Exit
// s
// i
// g
// n
// a
// b
// l
// e
// _
// v

// Answer: is_move_assignable_v

Solution 17

void run() {
{
static S object_1("t", "t"); // t
}
S object_2("i", "e"); // i
static S object_3("m", "_"); // m
} // e

// Program Exit
// _
// t

// Answer: time_t
Solutions 102

Solution 18

void run() {
static S object_1("u", "t"); // u
{
static S object_2("i", "_"); // i
}
static S object_3("n", "2"); // n
S object_4("t", "3"); // t
} // 3

// Program Exit
// 2
// _
// t

// Answer: uint32_t

Solution 19

void run() {
S object_1("r", "i"); // r
static S object_2("a", "n"); // a
{
S object_3("n", "g"); // n
} // g
S object_4("e", ":"); // e
{
S object_5("s", ":"); // s
} // :
} // :
// i

// Program Exit
// n

// Answer: ranges::in
Solutions 103

Solution 20
void run() {
S object_1("s", "d"); // s
S object_2("t", "r"); // t
{
S object_3("r", "o"); // r
} // o
{
S object_4("n", "_"); // n
static S object_5("g", "r"); // g
} // _
static S object_6("o", "e"); // o
} // r
// d

// Program Exit
// e
// r

// Answer: strong_order

Solution 21
void run() {
static S object_1("o", "r"); // o
S object_2("v", "r"); // v
static S object_3("e", "o"); // e
{
S object_4("r", "f"); // r
} // f
S object_5("l", "e"); // l
static S object_6("o", "r"); // o
S object_7("w", "_"); // w
} // _
// e
// r

// Program Exit
// r
// o
// r

// Answer: overflow_error
Solutions 104

Solution 22

void run() {
{
{
S object_1("c", "b"); // c
{
static S object_2("t", "k"); // t
S object_3("y", "p"); // y
} // p
S object_4("e", "_"); // e
} // _
// b
S object_5("a", ":"); // a
static S object_6("s", "s"); // s
S object_7("e", ":"); // e
} // :
// :
S object_8("m", "a"); // m
} // a

// Program Exit
// s
// k

// Answer: ctype_base::mask

Solution 23

void run() {
{
{
S object_1("t", "_"); // t
{
static S object_2("h", "d"); // h
}
S object_3("i", "s"); // i
} // s
// _
static S object_4("t", "l"); // t
{
S object_5("h", ":"); // h
static S object_6("r", "e"); // r
Solutions 105

S object_7("e", "d"); // e
static S object_8("a", "i"); // a
} // d
// :
S object_9(":", "y"); // :
} // y
}

// Program Exit
// i
// e
// l
// d

// Answer: this_thread::yield

Solution 24

void run() {
{
{
static S object_1("r", "e"); // r
}
{
static S object_2("a", "g"); // a
}
S object_3("n", "g"); // n
} // g
S object_4("e", "o"); // e
{
static S object_5("s", "n"); // s
}
static S object_6(":", "a"); // :
static S object_7(":", "r"); // :
S object_8("c", "m"); // c
static S object_9("o", "_"); // o
static S object_10("m", "n"); // m
} // m
// o

// Program Exit
// n
// _
Solutions 106

// r
// a
// n
// g
// e

// Answer: ranges::common_range

Solution 25

void run() {
S *object_1 = new S("l", "c"); // l
S *object_2 = nullptr;
object_2 = new S("o", "g"); // o
delete object_1; // c
S *object_3 = new S("k", "y"); // k
}

// Answer: lock

Solution 26

void run() {
{
S *object_1 = nullptr;
S *object_2 = new S("i", "l"); // i
}
S *object_3 = nullptr;
S *object_4 = new S("f", "b"); // f
}

// Answer: if
Solutions 107

Solution 27

void run() {
S *object_1 = nullptr;
object_1 = new S("b", "x"); // b
S *object_2 = new S("a", "v"); // a
S *object_3 = nullptr;
{
S *object_4 = new S("d", "e"); // d
S *object_5 = nullptr;
}
}

// Answer: bad

Solution 28

void run() {
S *object_1 = nullptr;
{
object_1 = new S("s", "t"); // s
delete object_1; // t
}
S *object_2 = nullptr;
S *object_3 = new S("r", "n"); // r
{
S *object_4 = nullptr;
}
object_2 = new S("c", "s"); // c
delete object_2; // s
S *object_5 = new S("p", "e"); // p
delete object_3; // n
S *object_6 = nullptr;
}

// Answer: strcspn
Solutions 108

Solution 29

void run() {
S *object_1 = nullptr;
{
S *object_2 = nullptr;
{
object_1 = new S("d", "c"); // d
S *object_3 = nullptr;
{
object_2 = new S("e", "v"); // e
S *object_4 = nullptr;
delete object_1; // c
object_3 = new S("l", "l"); // l
}
delete object_2; // v
S *object_5 = new S("a", "o"); // a
S *object_6 = nullptr;
delete object_3; // l
S *object_7 = nullptr;
}
}
}

// Answer: declval

Solution 30

void run() {
S *object_1 = nullptr;
{
}
S *object_2 = new S("s", "j"); // s
object_1 = new S("w", "l"); // w
{
S *object_3 = new S("i", "g"); // i
S *object_4 = nullptr;
{
S *object_5 = new S("t", "c"); // t
S *object_6 = nullptr;
object_4 = new S("c", "v"); // c
S *object_7 = nullptr;
S *object_8 = new S("h", "u"); // h
Solutions 109

}
}
}

// Answer: switch

Solution 31

void run() {
S *object_1 = nullptr;
{
S *object_2 = new S("b", "d"); // b
{
S *object_3 = new S("a", "n"); // a
delete object_2; // d
S *object_4 = new S("_", "c"); // _
object_1 = new S("a", "v"); // a
delete object_3; // n
S *object_5 = nullptr;
object_5 = new S("y", "s"); // y
S *object_6 = new S("_", "r"); // _
delete object_4; // c
{
S *object_7 = new S("a", "j"); // a
delete object_5; // s
{
S *object_8 = nullptr;
S *object_9 = new S("t", "m"); // t
}
}
}
}
}

// Answer: bad_any_cast
Solutions 110

Solution 32
void run() {
{
S *object_1 = nullptr;
object_1 = new S("T", "f"); // T
S *object_2 = new S("r", "v"); // r
S *object_3 = nullptr;
{
object_3 = new S("i", "j"); // i
delete object_2; // v
}
S *object_4 = nullptr;
}
S *object_5 = nullptr;
S *object_6 = nullptr;
S *object_7 = new S("i", "n"); // i
{
object_5 = new S("a", "q"); // a
S *object_8 = new S("l", "i"); // l
}
{
S *object_9 = new S("T", "k"); // T
object_6 = new S("y", "p"); // y
}
delete object_6; // p
S *object_10 = new S("e", "k"); // e
}

// Answer: TrivialType

Solution 33
void run() {
S *object_1 = new S("m", "h"); // m
S *object_2 = nullptr;
S *object_3 = new S("i", "g"); // i
object_2 = new S("c", "w"); // c
S *object_4 = new S("r", "d"); // r
S *object_5 = new S("o", "x"); // o
}

// Answer: micro
Solutions 111

Solution 34

void run() {
{
S object_1("l", "c"); // l
S *object_2 = new S("o", "q"); // o
S *object_3 = nullptr;
} // c
S *object_4 = new S("a", "q"); // a
S object_5("l", "e"); // l
S *object_6 = nullptr;
} // e

// Answer: locale

Solution 35

void run() {
{
}
{
S *object_1 = nullptr;
S object_2("g", "e"); // g
} // e
S object_3("t", "r"); // t
S *object_4 = new S("c", "r"); // c
S *object_5 = new S("h", "m"); // h
S *object_6 = new S("a", "y"); // a
} // r

// Answer: getchar

Solution 36

void run() {
{
S *object_1 = new S("f", "h"); // f
{
S *object_2 = nullptr;
S object_3("t", "e"); // t
} // e
S *object_4 = nullptr;
}
Solutions 112

S object_5("l", "l"); // l
S *object_6 = nullptr;
S *object_7 = nullptr;
} // l

// Answer: ftell

Solution 37

void run() {
S *object_1 = new S("s", "a"); // s
{
S object_2("p", "e"); // p
{
delete object_1; // a
{
S object_3("n", "t"); // n
S *object_4 = nullptr;
S *object_5 = new S("s", "w"); // s
} // t
S *object_6 = nullptr;
object_6 = new S("r", "j"); // r
}
} // e
S object_7("a", "m"); // a
S *object_8 = nullptr;
} // m

// Answer: spanstream

Solution 38

void run() {
{
{
S *object_1 = nullptr;
object_1 = new S("l", "d"); // l
S object_2("o", "a"); // o
S *object_3 = nullptr;
object_3 = new S("c", "h"); // c
} // a
{
}
Solutions 113

S *object_4 = new S("l", "u"); // l


}
S object_5("e", "d"); // e
S *object_6 = new S(":", "i"); // :
S *object_7 = new S(":", "a"); // :
S *object_8 = nullptr;
delete object_6; // i
S *object_9 = nullptr;
} // d

// Answer: locale::id

Solution 39

void run() {
S *object_1 = new S("c", "h"); // c
{
S object_2("o", "n"); // o
S *object_3 = new S("n", "b"); // n
S object_4("d", "o"); // d
S *object_5 = nullptr;
S *object_6 = new S("i", "u"); // i
object_5 = new S("t", "d"); // t
S *object_7 = nullptr;
{
S *object_8 = new S("i", "p"); // i
S *object_9 = nullptr;
}
} // o
// n
}

// Answer: condition
Solutions 114

Solution 40

void run() {
{
S object_1("i", "n"); // i
} // n
{
}
S *object_2 = new S("c", "l"); // c
S *object_3 = nullptr;
delete object_2; // l
{
S object_4("u", "_"); // u
S *object_5 = new S("s", "r"); // s
S object_6("i", "e"); // i
object_3 = new S("v", "l"); // v
} // e
// _
S *object_7 = new S("s", "s"); // s
{
S *object_8 = new S("c", "r"); // c
S object_9("a", "n"); // a
S *object_10 = nullptr;
} // n
}

// Answer: inclusive_scan

Solution 41

void run() {
{
static S object_1("m", "e"); // m
S *object_2 = new S("k", "t"); // k
S *object_3 = nullptr;
delete object_2; // t
}
S *object_4 = new S("i", "m"); // i
delete object_4; // m
S *object_5 = nullptr;
}

// Program Exit
Solutions 115

// e

// Answer: mktime

Solution 42

void run() {
static S object_1("s", "m"); // s
{
static S object_2("s", "a"); // s
}
S *object_3 = new S("t", "u"); // t
S *object_4 = nullptr;
static S object_5("r", "e"); // r
S *object_6 = nullptr;
}

// Program Exit
// e
// a
// m

// Answer: sstream

Solution 43

void run() {
{
S *object_1 = new S("n", "m"); // n
static S object_2("u", "t"); // u
{
delete object_1; // m
S *object_3 = nullptr;
object_3 = new S("p", "a"); // p
}
static S object_4("u", "c"); // u
}
S *object_5 = new S("n", "v"); // n
S *object_6 = nullptr;
}

// Program Exit
// c
Solutions 116

// t

// Answer: numpunct

Solution 44

void run() {
{
}
{
S *object_1 = nullptr;
}
static S object_2("c", "t"); // c
S *object_3 = new S("h", "3"); // h
S *object_4 = nullptr;
object_4 = new S("a", "r"); // a
static S object_5("r", "_"); // r
S *object_6 = nullptr;
delete object_3; // 3
S *object_7 = new S("2", "a"); // 2
}

// Program Exit
// _
// t

// Answer: char32_t

Solution 45

void run() {
S *object_1 = new S("R", "e"); // R
{
delete object_1; // e
S *object_2 = new S("g", "l"); // g
S *object_3 = nullptr;
object_3 = new S("e", "r"); // e
static S object_4("x", "s"); // x
S *object_5 = nullptr;
object_5 = new S("T", "j"); // T
S *object_6 = nullptr;
delete object_3; // r
S *object_7 = nullptr;
Solutions 117

object_6 = new S("a", "u"); // a


static S object_8("i", "t"); // i
}
}

// Program Exit
// t
// s

// Answer: RegexTraits

Solution 46
void run() {
static S object_1("a", "e"); // a
{
S *object_2 = nullptr;
{
S *object_3 = nullptr;
static S object_4("n", "u"); // n
S *object_5 = new S("y", "_"); // y
S *object_6 = nullptr;
object_3 = new S(":", "h"); // :
{
object_2 = new S(":", "v"); // :
delete object_3; // h
object_6 = new S("a", "p"); // a
S *object_7 = new S("s", "b"); // s
}
delete object_5; // _
delete object_2; // v
}
S *object_8 = nullptr;
}
static S object_9("a", "l"); // a
}

// Program Exit
// l
// u
// e

// Answer: any::has_value
Solutions 118

Solution 47

void run() {
{
S *object_1 = nullptr;
}
S *object_2 = new S("i", "v"); // i
S *object_3 = nullptr;
S *object_4 = new S("s", "b"); // s
static S object_5("_", "t"); // _
object_3 = new S("c", "o"); // c
static S object_6("o", "s"); // o
{
S *object_7 = new S("n", "l"); // n
}
S *object_8 = nullptr;
{
S *object_9 = nullptr;
}
}

// Program Exit
// s
// t

// Answer: is_const

Solution 48

void run() {
S *object_1 = new S("N", "x"); // N
{
S *object_2 = nullptr;
{
S *object_3 = nullptr;
S *object_4 = new S("u", "u"); // u
static S object_5("m", "e"); // m
}
static S object_6("e", "p"); // e
}
{
S *object_7 = new S("r", "T"); // r
S *object_8 = nullptr;
Solutions 119

{
object_8 = new S("i", "e"); // i
static S object_9("c", "y"); // c
}
delete object_7; // T
S *object_10 = nullptr;
}
}

// Program Exit
// y
// p
// e

// Answer: NumericType

Solution 49

void run() {
S *object_1 = nullptr;
S object_2("l", "l"); // l
object_1 = new S("o", "g"); // o
delete object_1; // g
{
}
S *object_3 = nullptr;
object_3 = new S("n", "r"); // n
S object_4("o", "a"); // o
delete object_3; // r
S *object_5 = new S("m", "k"); // m
} // a
// l

// Answer: lognormal
Solutions 120

Solution 50

void run() {
{
}
static S object_1("u", "g"); // u
S object_2("3", "r"); // 3
S *object_3 = nullptr;
static S object_4("2", "n"); // 2
object_3 = new S("s", "y"); // s
static S object_5("t", "i"); // t
} // r

// Program Exit
// i
// n
// g

// Answer: u32string

Solution 51

void run() {
S object_1("i", "t"); // i
S object_2("n", "p"); // n
static S object_3("o", "t"); // o
S *object_4 = new S("u", "y"); // u
static S object_5("t", "_"); // t
{
static S object_6("_", "r"); // _
}
} // p
// t

// Program Exit
// r
// _
// t

// Answer: inout_ptr_t
Solutions 121

Solution 52

void run() {
static S object_1("s", "f"); // s
S object_2("y", "b"); // y
S *object_3 = nullptr;
S *object_4 = nullptr;
{
static S object_5("n", "u"); // n
S *object_6 = new S("c", "n"); // c
}
} // b

// Program Exit
// u
// f

// Answer: syncbuf

Solution 53

void run() {
static S object_1("s", "l"); // s
S *object_2 = new S("q", "r"); // q
S *object_3 = nullptr;
delete object_2; // r
S *object_4 = nullptr;
{
S *object_5 = new S("t", "c"); // t
}
S *object_6 = nullptr;
}

// Program Exit
// l

// Answer: sqrtl
Solutions 122

Solution 54

void run() {
static S object_1("c", "l"); // c
S object_2("h", "i"); // h
{
S object_3("r", "o"); // r
{
S object_4("o", "n"); // o
} // n
} // o
S *object_5 = nullptr;
object_5 = new S(":", "l"); // :
S *object_6 = new S(":", "q"); // :
S object_7("c", "e"); // c
} // e
// i

// Program Exit
// l

// Answer: chrono::ceil

Solution 55

void run() {
static S object_1("s", "e"); // s
S object_2("t", "z"); // t
{
S *object_3 = nullptr;
object_3 = new S("r", "k"); // r
}
S *object_4 = nullptr;
{
S *object_5 = new S("e", "o"); // e
object_4 = new S("a", "m"); // a
delete object_4; // m
S *object_6 = new S("s", "o"); // s
}
S *object_7 = new S("i", "m"); // i
} // z

// Program Exit
Solutions 123

// e

// Answer: streamsize

Solution 56

void run() {
{
{
static S object_1("o", "m"); // o
S *object_2 = nullptr;
object_2 = new S("f", "n"); // f
static S object_3("s", "a"); // s
S *object_4 = nullptr;
}
S *object_5 = nullptr;
S object_6("t", "e"); // t
S *object_7 = new S("r", "r"); // r
} // e
}

// Program Exit
// a
// m

// Answer: ofstream

Solution 57

void run() {
static S object_1("r", "f"); // r
{
S *object_2 = nullptr;
object_2 = new S("i", "i"); // i
}
{
S *object_3 = new S("e", "m"); // e
{
delete object_3; // m
S object_4("a", "e"); // a
S *object_5 = new S("n", "n"); // n
delete object_5; // n
S object_6("_", "z"); // _
Solutions 124

} // z
// e
S object_7("t", "a"); // t
S *object_8 = nullptr;
} // a
}

// Program Exit
// f

// Answer: riemann_zetaf

Solution 58

void run() {
{
S *object_1 = new S("e", "o"); // e
}
S object_2("q", "n"); // q
{
S *object_3 = nullptr;
static S object_4("u", "e"); // u
}
S *object_5 = new S("a", "l"); // a
delete object_5; // l
S *object_6 = new S("_", "r"); // _
static S object_7("r", "g"); // r
{
S *object_8 = new S("a", "t"); // a
}
} // n

// Program Exit
// g
// e

// Answer: equal_range
Solutions 125

Solution 59

void run() {
{
S object_1("f", "e"); // f
} // e
{
{
}
static S object_2("s", "d"); // s
S object_3("e", "t"); // e
S *object_4 = nullptr;
} // t
S *object_5 = nullptr;
S *object_6 = new S("r", "q"); // r
S *object_7 = new S("o", "q"); // o
S object_8("u", "n"); // u
} // n

// Program Exit
// d

// Answer: fesetround

Solution 60

void run() {
S object_1("s", "f"); // s
S *object_2 = nullptr;
static S object_3("e", "r"); // e
{
object_2 = new S("n", "n"); // n
static S object_4("t", "o"); // t
S *object_5 = nullptr;
S *object_6 = new S("i", "y"); // i
delete object_2; // n
S *object_7 = nullptr;
S object_8("e", "_"); // e
S *object_9 = new S("l", "g"); // l
} // _
} // f

// Program Exit
Solutions 126

// o
// r

// Answer: sentinel_for

Solution 61

void run() {
{
static S object_1("i", "l"); // i
S *object_2 = nullptr;
{
object_2 = new S("s", "u"); // s
S *object_3 = nullptr;
{
S *object_4 = new S("_", "m"); // _
}
S object_5("f", "a"); // f
delete object_2; // u
object_3 = new S("n", "v"); // n
S *object_6 = new S("d", "y"); // d
} // a
S *object_7 = new S("m", "e"); // m
delete object_7; // e
static S object_8("n", "a"); // n
}
S *object_9 = new S("t", "w"); // t
}

// Program Exit
// a
// l

// Answer: is_fundamental
Solutions 127

Solution 62

void run() {
S *object_1 = nullptr;
{
S *object_2 = new S("a", "o"); // a
static S object_3("l", "g"); // l
S *object_4 = new S("l", "n"); // l
{
object_1 = new S("o", "l"); // o
S object_5("c", "a"); // c
S *object_6 = new S("a", "v"); // a
{
static S object_7("t", "r"); // t
{
delete object_2; // o
}
S *object_8 = nullptr;
}
S object_9("r", "_"); // r
} // _
// a
}
}

// Program Exit
// r
// g

// Answer: allocator_arg

Solution 63

void run() {
{
S *object_1 = new S("d", "y"); // d
static S object_2("e", "t"); // e
S *object_3 = nullptr;
object_3 = new S("s", "w"); // s
S *object_4 = nullptr;
S object_5("t", "r"); // t
S *object_6 = nullptr;
} // r
Solutions 128

{
S object_7("o", "a"); // o
{
S *object_8 = nullptr;
S *object_9 = new S("y", "y"); // y
{
S *object_10 = new S("_", "y"); // _
}
}
} // a
}

// Program Exit
// t

// Answer: destroy_at

Solution 64

void run() {
S object_1("i", "a"); // i
S *object_2 = new S("o", "e"); // o
{
S object_3("s", "_"); // s
} // _
static S object_4("b", "s"); // b
S object_5("a", "l"); // a
S object_6("s", "f"); // s
delete object_2; // e
S *object_7 = new S(":", "s"); // :
static S object_8(":", "g"); // :
S *object_9 = nullptr;
S *object_10 = nullptr;
} // f
// l
// a

// Program Exit
// g
// s

// Answer: ios_base::flags
Solutions 129

Solution 65
void run() {
thread_local S object_1("m", "4"); // m
{
thread_local S object_2("t", "6"); // t
}
thread_local S object_3("1", "_"); // 1
thread_local S object_4("9", "7"); // 9
thread_local S object_5("9", "3"); // 9
}

// Main Thread Exit


// 3
// 7
// _
// 6
// 4

// Answer: mt19937_64

Solution 66
void run() {
{
thread_local S object_1("p", "g"); // p
}
thread_local S object_2("m", "n"); // m
thread_local S object_3("r", "i"); // r
thread_local S object_4(":", "r"); // :
thread_local S object_5(":", "t"); // :
thread_local S object_6("w", "s"); // w
}

// Main Thread Exit


// s
// t
// r
// i
// n
// g

// Answer: pmr::wstring
Solutions 130

Solution 67

void run() {
{
{
thread_local S object_1("c", "l"); // c
}
thread_local S object_2("y", "n"); // y
}
thread_local S object_3("l", "n"); // l
thread_local S object_4("_", "a"); // _
thread_local S object_5("n", "m"); // n
thread_local S object_6("e", "u"); // e
}

// Main Thread Exit


// u
// m
// a
// n
// n
// l

// Answer: cyl_neumannl

Solution 68

void run() {
{
thread_local S object_1("i", "t"); // i
}
{
thread_local S object_2("o", "i"); // o
}
thread_local S object_3("s", "n"); // s
thread_local S object_4("_", "I"); // _
thread_local S object_5("b", ":"); // b
thread_local S object_6("a", ":"); // a
thread_local S object_7("s", "e"); // s
}

// Main Thread Exit


// e
Solutions 131

// :
// :
// I
// n
// i
// t

// Answer: ios_base::Init

Solution 69

void run() {
{
thread_local S object_1("r", "w"); // r
{
thread_local S object_2("a", "e"); // a
{
thread_local S object_3("n", "i"); // n
}
thread_local S object_4("g", "v"); // g
}
thread_local S object_5("e", "_"); // e
}
thread_local S object_6("s", "p"); // s
thread_local S object_7(":", "i"); // :
thread_local S object_8(":", "z"); // :
}

// Main Thread Exit


// z
// i
// p
// _
// v
// i
// e
// w

// Answer: ranges::zip_view
Solutions 132

Solution 70

void run() {
{
{
thread_local S object_1("n", "e"); // n
}
{
thread_local S object_2("u", "m"); // u
}
thread_local S object_3("m", "a"); // m
}
thread_local S object_4("p", "n"); // p
thread_local S object_5("u", "e"); // u
thread_local S object_6("n", "u"); // n
thread_local S object_7("c", "r"); // c
thread_local S object_8("t", "t"); // t
thread_local S object_9(":", ":"); // :
}

// Main Thread Exit


// :
// t
// r
// u
// e
// n
// a
// m
// e

// Answer: numpunct::truename

Solution 71

void run() {
{
thread_local S object_1("i", "r"); // i
}
thread_local S object_2("d", "o"); // d
{
thread_local S object_3("e", "t"); // e
{
Solutions 133

thread_local S object_4("n", "a"); // n


{
thread_local S object_5("t", "r"); // t
}
thread_local S object_6("i", "e"); // i
}
thread_local S object_7("t", "p"); // t
}
thread_local S object_8("y", "o"); // y
thread_local S object_9(":", ":"); // :
}

// Main Thread Exit


// :
// o
// p
// e
// r
// a
// t
// o
// r

// Answer: identity::operator

Solution 72

void run() {
{
thread_local S object_1("r", "t"); // r
}
{
thread_local S object_2("a", "l"); // a
}
thread_local S object_3("n", "u"); // n
{
thread_local S object_4("g", "s"); // g
{
thread_local S object_5("e", "e"); // e
}
thread_local S object_6("s", "r"); // s
}
thread_local S object_7(":", "_"); // :
Solutions 134

thread_local S object_8(":", "n"); // :


thread_local S object_9("i", "i"); // i
thread_local S object_10("n", "_"); // n
}

// Main Thread Exit


// _
// i
// n
// _
// r
// e
// s
// u
// l
// t

// Answer: ranges::in_in_result

Solution 73

void run() {
{
static S object_1("a", "f"); // a
}
static S object_2("t", "e"); // t
static S object_3("o", "r"); // o
thread_local S object_4("m", "c"); // m
static S object_5("i", "_"); // i
}

// Main Thread Exit


// c

// Program Exit
// _
// r
// e
// f

// Answer: atomic_ref
Solutions 135

Solution 74

void run() {
{
thread_local S object_1("t", "t"); // t
}
thread_local S object_2("x", "p"); // x
static S object_3("_", "n"); // _
thread_local S object_4("e", "e"); // e
static S object_5("x", "o"); // x
static S object_6("c", "i"); // c
}

// Main Thread Exit


// e
// p
// t

// Program Exit
// i
// o
// n

// Answer: tx_exception

Solution 75

void run() {
thread_local S object_1("s", "i"); // s
{
static S object_2("i", "t"); // i
thread_local S object_3("g", "m"); // g
static S object_4("_", "_"); // _
{
thread_local S object_5("a", "o"); // a
}
static S object_6("t", "c"); // t
}
}

// Main Thread Exit


// o
// m
Solutions 136

// i

// Program Exit
// c
// _
// t

// Answer: sig_atomic_t

Solution 76

void run() {
thread_local S object_1("u", "t"); // u
thread_local S object_2("n", "c"); // n
{
static S object_3("a", "n"); // a
thread_local S object_4("r", "n"); // r
{
static S object_5("y", "o"); // y
}
static S object_6("_", "i"); // _
thread_local S object_7("f", "u"); // f
}
}

// Main Thread Exit


// u
// n
// c
// t

// Program Exit
// i
// o
// n

// Answer: unary_function
Solutions 137

Solution 77

void run() {
static S object_1("u", "e"); // u
{
static S object_2("n", "c"); // n
{
thread_local S object_3("w", "e"); // w
}
thread_local S object_4("r", "f"); // r
}
{
static S object_5("a", "n"); // a
}
static S object_6("p", "e"); // p
thread_local S object_7("_", "e"); // _
static S object_8("r", "r"); // r
}

// Main Thread Exit


// e
// f
// e

// Program Exit
// r
// e
// n
// c
// e

// Answer: unwrap_reference

Solution 78

void run() {
static S object_1("u", "y"); // u
thread_local S object_2("n", "d"); // n
static S object_3("i", "p"); // i
{
static S object_4("n", "o"); // n
thread_local S object_5("i", "e"); // i
}
Solutions 138

{
static S object_6("t", "c"); // t
thread_local S object_7("i", "z"); // i
}
{
static S object_8("a", "_"); // a
thread_local S object_9("l", "i"); // l
}
}

// Main Thread Exit


// i
// z
// e
// d

// Program Exit
// _
// c
// o
// p
// y

// Answer: uninitialized_copy

Solution 79

void run() {
{
{
static S object_1("o", "e"); // o
{
thread_local S object_2("s", "f"); // s
}
static S object_3("t", "z"); // t
{
static S object_4("r", "e"); // r
}
static S object_5("s", "e"); // s
}
thread_local S object_6("t", ":"); // t
static S object_7("r", "r"); // r
thread_local S object_8("e", ":"); // e
Solutions 139

}
thread_local S object_9("a", "m"); // a
}

// Main Thread Exit


// m
// :
// :
// f

// Program Exit
// r
// e
// e
// z
// e

// Answer: ostrstream::freeze

Solution 80

void run() {
static S object_1("t", "h"); // t
{
thread_local S object_2("o", "_"); // o
static S object_3("t", "t"); // t
thread_local S object_4("a", "d"); // a
}
{
static S object_5("l", "i"); // l
{
thread_local S object_6("l", "e"); // l
{
thread_local S object_7("y", "r"); // y
}
static S object_8("_", "w"); // _
}
thread_local S object_9("o", "e"); // o
}
thread_local S object_10("r", "d"); // r
}

// Main Thread Exit


Solutions 140

// d
// e
// r
// e
// d
// _

// Program Exit
// w
// i
// t
// h

// Answer: totally_ordered_with

Solution 81

void run() {
thread_local S object_1("a", "k"); // a
thread_local S object_2("d", "c"); // d
thread_local S object_3("o", "o"); // o
{
S object_4("p", "t"); // p
} // t
thread_local S object_5("_", "l"); // _
}

// Main Thread Exit


// l
// o
// c
// k

// Answer: adopt_lock
Solutions 141

Solution 82
void run() {
S object_1("r", "j"); // r
thread_local S object_2("a", "n"); // a
{
S object_3("n", "g"); // n
} // g
S object_4("e", ":"); // e
thread_local S object_5("s", "i"); // s
thread_local S object_6(":", "o"); // :
} // :
// j

// Main Thread Exit


// o
// i
// n

// Answer: ranges::join

Solution 83
void run() {
thread_local S object_1("c", "8"); // c
thread_local S object_2("o", "f"); // o
{
S object_3("d", "c"); // d
thread_local S object_4("e", "t"); // e
} // c
S object_5("v", "_"); // v
{
thread_local S object_6("t", "u"); // t
}
} // _

// Main Thread Exit


// u
// t
// f
// 8

// Answer: codecvt_utf8
Solutions 142

Solution 84

void run() {
S object_1("s", "b"); // s
{
S object_2("t", "o"); // t
} // o
{
thread_local S object_3("p", "s"); // p
}
thread_local S object_4("_", "k"); // _
thread_local S object_5("c", "c"); // c
thread_local S object_6("a", "a"); // a
S object_7("l", "l"); // l
} // l
// b

// Main Thread Exit


// a
// c
// k
// s

// Answer: stop_callbacks

Solution 85

void run() {
{
S object_1("r", "e"); // r
{
thread_local S object_2("a", "d"); // a
}
S object_3("n", "g"); // n
} // g
// e
{
thread_local S object_4("s", "n"); // s
S object_5(":", ":"); // :
} // :
S object_6("f", "_"); // f
S object_7("i", "d"); // i
thread_local S object_8("n", "e"); // n
Solutions 143

} // d
// _

// Main Thread Exit


// e
// n
// d

// Answer: ranges::find_end

Solution 86

void run() {
{
S object_1("r", "n"); // r
thread_local S object_2("a", "n"); // a
{
S object_3("n", "g"); // n
} // g
thread_local S object_4("e", "_"); // e
S object_5("s", "e"); // s
{
S object_6(":", ":"); // :
} // :
thread_local S object_7("g", "e"); // g
} // e
// n
thread_local S object_8("e", "t"); // e
S object_9("r", "a"); // r
} // a

// Main Thread Exit


// t
// e
// _
// n

// Answer: ranges::generate_n
Solutions 144

Solution 87

void run() {
{
{
thread_local S object_1("i", "m"); // i
{
S object_2("s", "o"); // s
{
S object_3("_", "e"); // _
} // e
S object_4("r", "r"); // r
} // r
// o
S object_5("r", "_"); // r
} // _
S object_6("c", "o"); // c
} // o
thread_local S object_7("d", "u"); // d
S object_8("e", "e"); // e
thread_local S object_9("_", "n"); // _
} // e

// Main Thread Exit


// n
// u
// m

// Answer: is_error_code_enum

Solution 88

void run() {
{
{
thread_local S object_1("t", "e"); // t
S object_2("h", "a"); // h
thread_local S object_3("r", "l"); // r
S object_4("e", "p"); // e
{
S object_5("e", "w"); // e
thread_local S object_6("_", "b"); // _
} // w
Solutions 145

thread_local S object_7("a", "a"); // a


{
thread_local S object_8("y", "r"); // y
S object_9("_", "c"); // _
} // c
S object_10("o", "m"); // o
} // m
// p
// a
}
}

// Main Thread Exit


// r
// a
// b
// l
// e

// Answer: three_way_comparable

Solution 89

void run() {
S *object_1 = new S("a", "r"); // a
{
S *object_2 = new S("c", "v"); // c
}
thread_local S object_3("o", "h"); // o
S *object_4 = nullptr;
S *object_5 = new S("s", "e"); // s
}

// Main Thread Exit


// h

// Answer: acosh
Solutions 146

Solution 90
void run() {
{
}
S *object_1 = nullptr;
object_1 = new S("e", "x"); // e
delete object_1; // x
S *object_2 = new S("p", "i"); // p
S *object_3 = new S("l", "k"); // l
delete object_2; // i
thread_local S object_4("c", "t"); // c
S *object_5 = nullptr;
S *object_6 = new S("i", "a"); // i
}

// Main Thread Exit


// t

// Answer: explicit

Solution 91
void run() {
S *object_1 = nullptr;
thread_local S object_2("p", "n"); // p
{
object_1 = new S("a", "r"); // a
delete object_1; // r
{
S *object_3 = nullptr;
S *object_4 = new S("t", "y"); // t
object_3 = new S("i", "a"); // i
}
S *object_5 = new S("t", "b"); // t
}
thread_local S object_6("i", "o"); // i
}

// Main Thread Exit


// o
// n

// Answer: partition
Solutions 147

Solution 92

void run() {
thread_local S object_1("m", "t"); // m
S *object_2 = new S("i", "d"); // i
delete object_2; // d
{
thread_local S object_3("p", "n"); // p
{
S *object_4 = nullptr;
S *object_5 = new S("o", "d"); // o
S *object_6 = nullptr;
}
S *object_7 = new S("i", "f"); // i
}
}

// Main Thread Exit


// n
// t

// Answer: midpoint

Solution 93

void run() {
{
S *object_1 = nullptr;
{
S *object_2 = new S("r", "a"); // r
S *object_3 = nullptr;
delete object_2; // a
thread_local S object_4("n", "d"); // n
}
thread_local S object_5("g", "n"); // g
{
}
object_1 = new S("e", "s"); // e
thread_local S object_6("s", "e"); // s
}
S *object_7 = new S(":", "p"); // :
thread_local S object_8(":", "r"); // :
}
Solutions 148

// Main Thread Exit


// r
// e
// n
// d

// Answer: ranges::rend

Solution 94

void run() {
{
{
S *object_1 = nullptr;
S *object_2 = new S("m", "h"); // m
object_1 = new S("o", "h"); // o
}
S *object_3 = new S("v", "e"); // v
{
delete object_3; // e
S *object_4 = new S("_", "q"); // _
}
}
thread_local S object_5("s", "l"); // s
S *object_6 = nullptr;
S *object_7 = new S("e", "n"); // e
delete object_7; // n
object_6 = new S("t", "i"); // t
S *object_8 = nullptr;
delete object_6; // i
thread_local S object_9("n", "e"); // n
}

// Main Thread Exit


// e
// l

// Answer: move_sentinel
Solutions 149

Solution 95

void run() {
S *object_1 = nullptr;
{
thread_local S object_2("c", "d"); // c
{
S *object_3 = new S("h", "k"); // h
thread_local S object_4("r", "n"); // r
{
S *object_5 = new S("o", "r"); // o
object_1 = new S("n", "n"); // n
}
thread_local S object_6("o", "u"); // o
thread_local S object_7(":", "o"); // :
S *object_8 = nullptr;
thread_local S object_9(":", "r"); // :
}
}
}

// Main Thread Exit


// r
// o
// u
// n
// d

// Answer: chrono::round

Solution 96

void run() {
{
thread_local S object_1("s", "e"); // s
}
{
}
{
}
S *object_2 = new S("h", "u"); // h
{
delete object_2; // u
Solutions 150

}
thread_local S object_3("f", "n"); // f
S *object_4 = new S("f", "e"); // f
thread_local S object_5("l", "i"); // l
delete object_4; // e
S *object_6 = new S("_", "o"); // _
delete object_6; // o
S *object_7 = new S("r", "r"); // r
thread_local S object_8("d", "g"); // d
S *object_9 = nullptr;
object_9 = new S("e", "_"); // e
delete object_7; // r
delete object_9; // _
thread_local S object_10("e", "n"); // e
}

// Main Thread Exit


// n
// g
// i
// n
// e

// Answer: shuffle_order_engine

Solution 97

void run() {
thread_local S object_1("a", "h"); // a
S *object_2 = nullptr;
S *object_3 = new S("s", "i"); // s
delete object_3; // i
S *object_4 = new S("n", "p"); // n
S *object_5 = nullptr;
}

// Main Thread Exit


// h

// Answer: asinh
Solutions 151

Solution 98
void run() {
{
S object_1("m", "n"); // m
thread_local S object_2("o", "t"); // o
S *object_3 = nullptr;
thread_local S object_4("n", "c"); // n
object_3 = new S("e", "y"); // e
S *object_5 = nullptr;
delete object_3; // y
S object_6("p", "u"); // p
} // u
// n
}

// Main Thread Exit


// c
// t

// Answer: moneypunct

Solution 99
void run() {
S *object_1 = new S("u", "n"); // u
delete object_1; // n
S *object_2 = new S("i", "e"); // i
S object_3("q", "o"); // q
{
S *object_4 = nullptr;
thread_local S object_5("u", "k"); // u
delete object_2; // e
object_4 = new S("_", "l"); // _
thread_local S object_6("l", "c"); // l
}
} // o

// Main Thread Exit


// c
// k

// Answer: unique_lock
Solutions 152

Solution 100
void run() {
S *object_1 = nullptr;
S *object_2 = new S("s", "r"); // s
{
object_1 = new S("t", "a"); // t
S *object_3 = new S("r", "d"); // r
{
S object_4("t", "o"); // t
} // o
S *object_5 = new S("u", "n"); // u
S *object_6 = nullptr;
S object_7("l", "l"); // l
} // l
}

// Answer: strtoull

Solution 101
void run() {
S object_1("i", "w"); // i
{
thread_local S object_2("o", "d"); // o
S object_3("s", "i"); // s
{
S object_4("_", ":"); // _
thread_local S object_5("b", "r"); // b
{
S object_6("a", "s"); // a
} // s
S *object_7 = new S("e", "p"); // e
} // :
thread_local S object_8(":", "o"); // :
} // i
} // w

// Main Thread Exit


// o
// r
// d

// Answer: ios_base::iword
Solutions 153

Solution 102

void run() {
thread_local S object_1("a", "e"); // a
S *object_2 = nullptr;
object_2 = new S("s", "l"); // s
{
thread_local S object_3("s", "r"); // s
S *object_4 = new S("o", "e"); // o
S object_5("c", "n"); // c
{
thread_local S object_6("_", "d"); // _
}
delete object_2; // l
S *object_7 = new S("e", "s"); // e
{
S object_8("g", "e"); // g
S *object_9 = nullptr;
} // e
} // n
}

// Main Thread Exit


// d
// r
// e

// Answer: assoc_legendre

Solution 103

void run() {
thread_local S object_1("s", "m"); // s
{
thread_local S object_2("t", "a"); // t
S *object_3 = new S("r", "e"); // r
}
thread_local S object_4("i", "e"); // i
S *object_5 = new S("n", "c"); // n
S *object_6 = nullptr;
S *object_7 = new S("g", "i"); // g
S object_8("s", "r"); // s
S *object_9 = new S("t", "x"); // t
Solutions 154

} // r

// Main Thread Exit


// e
// a
// m

// Answer: stringstream

Solution 104

void run() {
S *object_1 = nullptr;
S *object_2 = nullptr;
{
}
thread_local S object_3("s", "l"); // s
S object_4("p", "a"); // p
{
S *object_5 = new S("h", "j"); // h
}
object_1 = new S("_", "n"); // _
{
S *object_6 = nullptr;
thread_local S object_7("n", "n"); // n
{
S *object_8 = nullptr;
thread_local S object_9("e", "n"); // e
S object_10("u", "m"); // u
} // m
}
} // a

// Main Thread Exit


// n
// n
// l

// Answer: sph_neumannl
Solutions 155

Solution 105

void run() {
S *object_1 = nullptr;
S *object_2 = new S("s", "h"); // s
{
S *object_3 = nullptr;
thread_local S object_4("p", "f"); // p
}
delete object_2; // h
S *object_5 = new S("_", "o"); // _
S("l", "e"); // l
// e
S *object_7 = nullptr;
S object_8("g", "r"); // g
{
object_1 = new S("e", "d"); // e
new S("n", "u"); // n
{
thread_local S object_10("d", "e"); // d
}
}
} // r

// Main Thread Exit


// e
// f

// Answer: sph_legendref

Solution 106

void run() {
delete new S("p", "m"); // p
// m
S *object_2 = new S("r", ":"); // r
delete object_2; // :
S(":", "u"); // :
// u
S *object_4 = new S("n", "l"); // n
delete new S("s", "y"); // s
// y
thread_local S object_6("n", "d"); // n
Solutions 156

S("c", "h"); // c
// h
thread_local S object_8("r", "e"); // r
{
S *object_9 = nullptr;
}
S object_10("o", "i"); // o
thread_local S object_11("n", "z"); // n
} // i

// Main Thread Exit


// z
// e
// d

// Answer: pmr::unsynchronized

Solution 107

void run() {
S object_1("m", "l"); // m
static S object_2("e", "d"); // e
S object_3("m", "e"); // m
S("o", "r"); // o
// r
static S object_5("y", "e"); // y
S *object_6 = new S("_", "r"); // _
{
S *object_7 = nullptr;
thread_local S object_8("o", "a"); // o
{
S object_9("r", "d"); // r
} // d
S object_10("e", "r"); // e
delete object_6; // r
static S object_11("_", "x"); // _
} // r
} // e
// l

// Main Thread Exit


// a
Solutions 157

// Program Exit
// x
// e
// d

// Answer: memory_order_relaxed

Solution 108

void run() {
{
thread_local S object_1("o", "a"); // o
S *object_2 = nullptr;
{
}
thread_local S object_3("u", "h"); // u
S *object_4 = nullptr;
object_2 = new S("t", "o"); // t
S *object_5 = new S("_", "e"); // _
{
delete object_2; // o
S object_6("f", "w"); // f
{
new S("_", "i"); // _
{
S object_8("r", "a"); // r
} // a
S object_9("n", ":"); // n
S *object_10 = nullptr;
static S object_11("g", "t"); // g
delete object_5; // e
object_4 = new S(":", "t"); // :
S *object_12 = nullptr;
} // :
} // w
}
}

// Main Thread Exit


// h
// a

// Program Exit
Solutions 158

// t

// Answer: out_of_range::what

Solution 109

void run() {
S object_1("r", ":"); // r
S("a", "n"); // a
// n
S object_3("g", ":"); // g
S("e", "s"); // e
// s
thread_local S object_5(":", "t"); // :
S *object_6 = nullptr;
S object_7(":", "w"); // :
{
thread_local S object_8("r", "p"); // r
S("e", "f"); // e
// f
}
thread_local S object_10("_", "m"); // _
object_6 = new S("v", "r"); // v
static S object_11("i", "y"); // i
S *object_12 = nullptr;
thread_local S object_13("e", "e"); // e
} // w
// :
// :

// Main Thread Exit


// e
// m
// p
// t

// Program Exit
// y

// Answer: ranges::ref_view::empty
Solutions 159

Solution 110

void run() {
{
thread_local S object_1("u", "a"); // u
S object_2("n", "p"); // n
static S object_3("d", "r"); // d
{
S *object_4 = nullptr;
delete new S("e", "r"); // e
// r
{
object_4 = new S("f", "p"); // f
{
S *object_6 = new S("l", "r"); // l
static S object_7("o", "o"); // o
S("w", "_"); // w
// _
S *object_9 = new S("e", "y"); // e
thread_local S object_10("r", "r"); // r
delete object_6; // r
{
S *object_11 = new S("o", "y"); // o
S("r", ":"); // r
// :
static S object_13(":", "t"); // :
thread_local S object_14("o", "e"); // o
}
}
}
}
} // p
}

// Main Thread Exit


// e
// r
// a

// Program Exit
// t
// o
// r
Solutions 160

// Answer: underflow_error::operator

Solution 111

void run() {
{
S *object_1 = new S("w", "f"); // w
thread_local S object_2("e", "t"); // e
{
S *object_3 = nullptr;
static S object_4("a", "r"); // a
thread_local S object_5("k", "a"); // k
S *object_6 = new S("_", "n"); // _
{
object_3 = new S("o", "d"); // o
{
static S object_7("r", "e"); // r
delete object_3; // d
S *object_8 = new S("e", "x"); // e
S object_9("r", "r"); // r
{
S *object_10 = new S("i", "d"); // i
delete object_6; // n
{
S *object_11 = new S("g", "u"); // g
}
new S(":", "g"); // :
thread_local S object_13(":", "e"); // :
S *object_14 = new S("g", "x"); // g
}
} // r
}
}
}
}

// Main Thread Exit


// e
// a
// t

// Program Exit
Solutions 161

// e
// r

// Answer: weak_ordering::greater

Solution 112

void run() {
S object_1("a", "p"); // a
{
S *object_2 = nullptr;
}
{
thread_local S object_3("t", "c"); // t
S object_4("o", "i"); // o
thread_local S object_5("m", "i"); // m
} // i
static S object_6("c", "t"); // c
S *object_7 = nullptr;
S *object_8 = new S("_", "a"); // _
thread_local S object_9("f", "l"); // f
object_7 = new S("e", "_"); // e
delete new S("t", "c"); // t
// c
S object_11("h", "x"); // h
S *object_12 = new S("_", "i"); // _
{
delete object_8; // a
S("d", "d"); // d
// d
delete object_7; // _
{
static S object_14("e", "i"); // e
S *object_15 = nullptr;
}
}
} // x
// p

// Main Thread Exit


// l
// i
// c
Solutions 162

// Program Exit
// i
// t

// Answer: atomic_fetch_add_explicit

Solution 113

void run() {
delete new S("r", "e"); // r
// e
S *object_2 = nullptr;
object_2 = new S("g", "i"); // g
S("e", "x"); // e
// x
{
static S object_4("_", "e"); // _
S object_5("t", "s"); // t
{
new S("r", "q"); // r
S *object_7 = new S("a", "h"); // a
}
delete object_2; // i
thread_local S object_8("t", "e"); // t
} // s
static S object_9(":", "m"); // :
{
thread_local S object_10(":", "t"); // :
{
static S object_11("l", "a"); // l
}
S object_12("o", "a"); // o
{
S object_13("o", "l"); // o
{
S *object_14 = nullptr;
}
S *object_15 = new S("k", "p"); // k
S object_16("u", "l"); // u
delete object_15; // p
{
S *object_17 = new S("_", "c"); // _
Solutions 163

delete object_17; // c
static S object_18("o", "n"); // o
}
} // l
// l
} // a
}

// Main Thread Exit


// t
// e

// Program Exit
// n
// a
// m
// e

// Answer: regex_traits::lookup_collatename

Solution 114

void run() {
static S object_1("r", "l"); // r
S *object_2 = nullptr;
{
object_2 = new S("a", "n"); // a
delete object_2; // n
S *object_3 = new S("g", "t"); // g
static S object_4("e", "e"); // e
{
S *object_5 = nullptr;
}
new S("s", "h"); // s
thread_local S object_7(":", "i"); // :
{
S *object_8 = new S(":", "l"); // :
delete object_3; // t
}
S *object_9 = new S("a", "e"); // a
S *object_10 = nullptr;
thread_local S object_11("k", "t"); // k
delete object_9; // e
Solutions 164

S object_12("_", "e"); // _
S("v", "i"); // v
// i
} // e
S *object_14 = nullptr;
thread_local S object_15("w", "n"); // w
static S object_16(":", "n"); // :
S *object_17 = new S(":", "c"); // :
{
S *object_18 = new S("s", "k"); // s
object_14 = new S("e", "v"); // e
S *object_19 = nullptr;
}
}

// Main Thread Exit


// n
// t
// i

// Program Exit
// n
// e
// l

// Answer: ranges::take_view::sentinel

Solution 115

void run() {
S *object_1 = new S("r", "a"); // r
delete object_1; // a
static S object_2("n", "e"); // n
thread_local S object_3("g", "n"); // g
S *object_4 = nullptr;
delete new S("e", "s"); // e
// s
S *object_6 = nullptr;
thread_local S object_7(":", "e"); // :
delete new S(":", "s"); // :
// s
S object_9("e", "d"); // e
thread_local S object_10("t", "r"); // t
Solutions 165

static S object_11("_", "c"); // _


{
thread_local S object_12("s", "e"); // s
}
{
S *object_13 = nullptr;
S object_14("y", "m"); // y
} // m
{
thread_local S object_15("m", "f"); // m
S *object_16 = nullptr;
}
S *object_17 = new S("e", "c"); // e
thread_local S object_18("t", "f"); // t
S("r", "i"); // r
// i
delete object_17; // c
thread_local S object_20("_", "i"); // _
} // d

// Main Thread Exit


// i
// f
// f
// e
// r
// e
// n

// Program Exit
// c
// e

// Answer: ranges::set_symmetric_difference
Solutions 166

Solution 116

void run() {
S object_1("p", "_"); // p
{
thread_local S object_2("m", "c"); // m
{
static S object_3("r", "e"); // r
S object_4(":", ":"); // :
S *object_5 = nullptr;
} // :
S *object_6 = nullptr;
thread_local S object_7("m", "o"); // m
{
S *object_8 = new S("e", "r"); // e
static S object_9("m", "t"); // m
new S("o", "i"); // o
delete object_8; // r
new S("y", "a"); // y
{
thread_local S object_12("_", "l"); // _
S("r", "e"); // r
// e
{
thread_local S object_14("s", "l"); // s
object_6 = new S("o", "r"); // o
static S object_15("u", "a"); // u
delete object_6; // r
S object_16("c", "o"); // c
thread_local S object_17("e", "a"); // e
{
S *object_18 = nullptr;
S *object_19 = new S(":", "r"); // :
}
S(":", "d"); // :
// d
} // o
}
}
}
} // _

// Main Thread Exit


Solutions 167

// a
// l
// l
// o
// c

// Program Exit
// a
// t
// e

// Answer: pmr::memory_resource::do_allocate

Solution 117

void run() {
thread_local S object_1("r", "e"); // r
thread_local S object_2("a", "r"); // a
{
S("n", "g"); // n
// g
thread_local S object_4("e", "_"); // e
S *object_5 = new S("s", ":"); // s
delete object_5; // :
static S object_6(":", "t"); // :
S object_7("u", "_"); // u
delete new S("n", "i"); // n
// i
S *object_9 = nullptr;
static S object_10("n", "l"); // n
{
S("i", "t"); // i
// t
new S("i", "e"); // i
{
static S object_13("a", "u"); // a
}
static S object_14("l", "s"); // l
delete new S("i", "z"); // i
// z
{
thread_local S object_16("e", "n"); // e
delete new S("d", "_"); // d
Solutions 168

// _
S object_18("c", "y"); // c
S *object_19 = new S("o", "i"); // o
new S("p", "o"); // p
S *object_21 = nullptr;
} // y
}
} // _
}

// Main Thread Exit


// n
// _
// r
// e

// Program Exit
// s
// u
// l
// t

// Answer: ranges::uninitialized_copy_n_result

Solution 118

void run() {
{
S *object_1 = nullptr;
{
object_1 = new S("t", " "); // t
{
S *object_2 = new S("y", "x"); // y
{
thread_local S object_3("p", "a"); // p
{
thread_local S object_4("e", "r"); // e
{
delete object_1; //
static S object_5("o", "r"); // o
thread_local S object_6("f", "e"); // f
}
S *object_7 = nullptr;
Solutions 169

S *object_8 = new S(" ", "p"); //


object_7 = new S("u", "o"); // u
thread_local S object_9("n", "t"); // n
delete object_7; // o
{
S *object_10 = nullptr;
delete new S("r", "d"); // r
// d
S object_12("e", "n"); // e
static S object_13("r", "o"); // r
object_10 = new S("e", "j"); // e
thread_local S object_14("d", "i"); // d
S *object_15 = new S("_", "v"); // _
static S object_16("m", "t"); // m
{
{
thread_local S object_17("a", "_"); // a
{
delete object_8; // p
}
S object_18(":", "o"); // :
thread_local S object_19(":", "t"); // :
S *object_20 = nullptr;
thread_local S object_21("c", "s"); // c
} // o
S *object_22 = nullptr;
}
} // n
}
}
}
}
}
}

// Main Thread Exit


// s
// t
// _
// i
// t
// e
// r
Solutions 170

// a

// Program Exit
// t
// o
// r

// Answer: type of unordered_map::const_iterator

Solution 119

void run() {
new S("r", "n"); // r
{
S *object_2 = nullptr;
object_2 = new S("a", "v"); // a
S *object_3 = new S("n", ":"); // n
{
thread_local S object_4("g", "u"); // g
S object_5("e", "e"); // e
{
{
S *object_6 = new S("s", "m"); // s
delete object_3; // :
{
new S(":", "u"); // :
S *object_8 = nullptr;
new S("u", "n"); // u
S object_10("n", "i"); // n
static S object_11("i", "t"); // i
S *object_12 = new S("n", "v"); // n
} // i
static S object_13("t", "l"); // t
{
S *object_14 = new S("i", "p"); // i
S object_15("a", "l"); // a
} // l
S *object_16 = nullptr;
S object_17("i", "r"); // i
object_16 = new S("z", "n"); // z
S *object_18 = new S("e", "j"); // e
delete new S("d", "_"); // d
// _
Solutions 171

delete object_6; // m
{
S *object_20 = new S("o", "k"); // o
S object_21("v", "_"); // v
S *object_22 = nullptr;
thread_local S object_23("e", "s"); // e
} // _
} // r
}
} // e
}
}

// Main Thread Exit


// s
// u

// Program Exit
// l
// t

// Answer: ranges::uninitialized_move_result

Solution 120

void run() {
S *object_1 = new S("b", "p"); // b
static S object_2("a", "d"); // a
S *object_3 = new S("s", "r"); // s
static S object_4("i", "i"); // i
S *object_5 = new S("c", "p"); // c
{
S *object_6 = new S("_", "m"); // _
}
{
delete new S("f", "o"); // f
// o
}
delete object_3; // r
S *object_8 = nullptr;
new S("m", "d"); // m
S("a", "t"); // a
// t
Solutions 172

S object_11("_", "x"); // _
{
thread_local S object_12("p", "g"); // p
}
object_8 = new S("a", "k"); // a
thread_local S object_13("r", "r"); // r
S object_14("s", "e"); // s
thread_local S object_15("e", "a"); // e
S object_16("_", "n"); // _
thread_local S object_17("c", "_"); // c
static S object_18("o", "_"); // o
{
S *object_19 = new S("n", "r"); // n
}
thread_local S object_20("t", "t"); // t
{
S object_21("e", "t"); // e
new S("x", "e"); // x
S *object_23 = nullptr;
} // t
S object_24(":", ":"); // :
} // :
// n
// e
// x

// Main Thread Exit


// t
// _
// a
// r
// g

// Program Exit
// _
// i
// d

// Answer: basic_format_parse_context::next_arg_id
Solutions 173

Solution 121

void run() {
{
static S object_1("c", "e"); // c
S *object_2 = new S("o", "i"); // o
static S object_3("n", "n"); // n
S *object_4 = new S("d", "e"); // d
{
new S("i", "h"); // i
S object_6("t", "n"); // t
delete object_2; // i
S *object_7 = new S("o", "r"); // o
} // n
}
static S object_8("_", "o"); // _
S object_9("v", "n"); // v
static S object_10("a", "_"); // a
thread_local S object_11("r", "i"); // r
{
}
new S("i", "p"); // i
static S object_13("a", "y"); // a
{
S *object_14 = new S("b", "f"); // b
}
thread_local S object_15("l", "t"); // l
{
S *object_16 = nullptr;
S *object_17 = new S("e", "d"); // e
}
static S object_18("_", "f"); // _
{
thread_local S object_19("a", "o"); // a
S *object_20 = nullptr;
new S("n", "m"); // n
}
S object_22("y", ":"); // y
new S(":", "s"); // :
S *object_24 = nullptr;
} // :
// n
Solutions 174

// Main Thread Exit


// o
// t
// i

// Program Exit
// f
// y
// _
// o
// n
// e

// Answer: condition_variable_any::notify_one

Solution 122

void run() {
S *object_1 = new S("e", "u"); // e
thread_local S object_2("x", "l"); // x
S object_3("e", "e"); // e
static S object_4("c", "y"); // c
S *object_5 = nullptr;
{
delete object_1; // u
object_5 = new S("t", "p"); // t
S *object_6 = nullptr;
}
static S object_7("i", "c"); // i
S *object_8 = new S("o", "g"); // o
S object_9("n", "c"); // n
{
S *object_10 = nullptr;
static S object_11(":", "i"); // :
{
S object_12(":", "n"); // :
delete object_5; // p
object_10 = new S("a", "o"); // a
S("r", "a"); // r
// a
{
S *object_14 = new S("l", "v"); // l
thread_local S object_15("l", "o"); // l
Solutions 175

S *object_16 = nullptr;
S object_17("e", "l"); // e
} // l
{
S object_18("_", "n"); // _
S *object_19 = new S("u", "e"); // u
} // n
{
thread_local S object_20("s", "p"); // s
{
thread_local S object_21("e", "_"); // e
}
S *object_22 = nullptr;
S object_23("q", "e"); // q
thread_local S object_24("u", "d"); // u
S *object_25 = nullptr;
} // e
} // n
}
} // c
// e

// Main Thread Exit


// d
// _
// p
// o
// l

// Program Exit
// i
// c
// y

// Answer: execution::parallel_unsequenced_policy
Solutions 176

Solution 123

void run() {
S *object_1 = nullptr;
object_1 = new S("w", "b"); // w
S object_2("h", "t"); // h
S("e", "t"); // e
// t
S *object_4 = new S("h", "a"); // h
S *object_5 = nullptr;
S *object_6 = nullptr;
{
S *object_7 = nullptr;
S *object_8 = new S("e", "g"); // e
}
thread_local S object_9("r", " "); // r
S *object_10 = new S(" ", "w"); //
S("r", "a"); // r
// a
static S object_12("n", "e"); // n
new S("d", "t"); // d
object_5 = new S(" ", "t"); //
S object_14("m", "a"); // m
{
S *object_15 = nullptr;
delete object_4; // a
S *object_16 = new S("y", "e"); // y
S object_17(" ", "i"); //
} // i
S *object_18 = nullptr;
thread_local S object_19("n", "a"); // n
S *object_20 = new S("t", "r"); // t
static S object_21("r", "c"); // r
object_6 = new S("o", "b"); // o
static S object_22("d", "a"); // d
object_18 = new S("u", "r"); // u
static S object_23("c", "r"); // c
delete new S("e", " "); // e
//
S object_25("a", "d"); // a
S *object_26 = new S(" ", "u"); //
} // d
// a
Solutions 177

// t

// Main Thread Exit


// a
//

// Program Exit
// r
// a
// c
// e

// Answer: whether rand may introduce a data race

Solution 124

void run() {
thread_local S object_1("t", "r"); // t
S object_2("y", "i"); // y
static S object_3("p", "r"); // p
delete new S("e", " "); // e
//
{
delete new S("o", "f"); // o
// f
{
S *object_6 = nullptr;
S object_7(" ", "e"); //
{
S *object_8 = new S("u", "x"); // u
}
S *object_9 = nullptr;
S *object_10 = new S("n", "b"); // n
static S object_11("o", "o"); // o
S object_12("r", "r"); // r
object_6 = new S("d", "e"); // d
delete object_6; // e
} // r
// e
S *object_13 = new S("d", "_"); // d
{
delete object_13; // _
S *object_14 = nullptr;
Solutions 178

static S object_15("s", "t"); // s


S *object_16 = new S("e", "m"); // e
}
S *object_17 = nullptr;
{
S *object_18 = nullptr;
}
object_17 = new S("t", "l"); // t
{
static S object_19(":", "a"); // :
thread_local S object_20(":", "e"); // :
S object_21("c", "l"); // c
delete new S("o", "n"); // o
// n
{
S("s", "t"); // s
// t
S *object_24 = nullptr;
S object_25("_", "o"); // _
delete object_17; // l
} // o
S object_26("c", "a"); // c
} // a
// l
{
thread_local S object_27("_", "t"); // _
}
}
} // i

// Main Thread Exit


// t
// e
// r

// Program Exit
// a
// t
// o
// r

// Answer: type of unordered_set::const_local_iterator


Solutions 179

Solution 125

void run() {
S *object_1 = nullptr;
S *object_2 = nullptr;
static S object_3("i", "v"); // i
S("s", "_"); // s
// _
S object_5("t", "t"); // t
S *object_6 = nullptr;
object_2 = new S("r", "i"); // r
delete object_2; // i
S *object_7 = nullptr;
thread_local S object_8("v", "e"); // v
S object_9("i", "c"); // i
S("a", "l"); // a
// l
S object_11("l", "u"); // l
S *object_12 = nullptr;
object_6 = new S("y", "u"); // y
{
S *object_13 = nullptr;
}
S("_", "d"); // _
// d
S *object_15 = nullptr;
S *object_16 = nullptr;
thread_local S object_17("e", "l"); // e
thread_local S object_18("f", "b"); // f
S *object_19 = nullptr;
S object_20("a", "r"); // a
{
delete object_6; // u
S *object_21 = new S("l", "n"); // l
static S object_22("t", "_"); // t
{
S *object_23 = nullptr;
}
S object_24("_", "t"); // _
{
S *object_25 = nullptr;
thread_local S object_26("c", "i"); // c
S *object_27 = new S("o", "h"); // o
Solutions 180

delete object_21; // n
}
{
S *object_28 = new S("s", "e"); // s
}
} // t
} // r
// u
// c
// t

// Main Thread Exit


// i
// b
// l
// e

// Program Exit
// _
// v

// Answer: is_trivially_default_constructible_v

Solution 126

void run() {
{
static S object_1("h", "s"); // h
}
delete new S("o", "w"); // o
// w
new S(" ", "o"); //
S object_4("r", "a"); // r
new S("a", "c"); // a
S *object_6 = nullptr;
{
S object_7("n", "m"); // n
static S object_8("d", "e"); // d
S *object_9 = new S("o", "x"); // o
} // m
{
static S object_10("_", "u"); // _
object_6 = new S("d", "o"); // d
Solutions 181

}
S object_11("e", "r"); // e
static S object_12("v", "l"); // v
delete new S("i", "c"); // i
// c
S object_14("e", "e"); // e
S *object_15 = nullptr;
static S object_16(":", "a"); // :
{
thread_local S object_17(":", "e"); // :
{
delete object_6; // o
S *object_18 = new S("p", "e"); // p
object_15 = new S("e", "h"); // e
S *object_19 = new S("r", "b"); // r
thread_local S object_20("a", "t"); // a
S("t", "o"); // t
// o
{
static S object_22("r", "v"); // r
S *object_23 = nullptr;
static S object_24("(", " "); // (
S *object_25 = new S(")", "d"); // )
}
{
S *object_26 = new S(" ", "x"); //
static S object_27("g", "s"); // g
delete object_18; // e
new S("n", "c"); // n
}
}
}
} // e
// r
// a

// Main Thread Exit


// t
// e

// Program Exit
// s
//
Solutions 182

// v
// a
// l
// u
// e
// s

// Answer: how random_device::operator() generates values

Solution 127

void run() {
{
static S object_1("a", "t"); // a
S *object_2 = nullptr;
S *object_3 = new S("l", "j"); // l
S object_4("l", "o"); // l
} // o
{
S *object_5 = new S("c", "o"); // c
{
static S object_6("a", "c"); // a
S object_7("t", " "); // t
static S object_8("i", "e"); // i
delete object_5; // o
{
static S object_9("n", "j"); // n
S *object_10 = new S(" ", "t"); //
{
S object_11("o", "a"); // o
{
static S object_12("f", "b"); // f
S *object_13 = nullptr;
S *object_14 = new S(" ", "s"); //
thread_local S object_15("b", " "); // b
static S object_16("i", "o"); // i
S *object_17 = nullptr;
delete object_10; // t
{
thread_local S object_18("-", "s"); // -
{
S *object_19 = nullptr;
thread_local S object_20("f", "s"); // f
Solutions 183

delete new S("i", "e"); // i


// e
object_17 = new S("l", "m"); // l
new S("d", "c"); // d
}
S *object_23 = nullptr;
delete object_14; // s
thread_local S object_24(" ", "a"); //
{
S object_25("w", " "); // w
thread_local S object_26("i", "l"); // i
S("t", "h"); // t
// h
thread_local S object_28("i", "c"); // i
S *object_29 = new S("n", "y"); // n
} //
}
}
} // a
}
} //
}
}

// Main Thread Exit


// c
// l
// a
// s
// s
//

// Program Exit
// o
// b
// j
// e
// c
// t

// Answer: allocation of bit-fields within a class object


Solutions 184

Solution 128

void run() {
static S object_1("r", "t"); // r
S object_2("a", "o"); // a
{
S *object_3 = new S("n", "b"); // n
S *object_4 = nullptr;
static S object_5("g", "l"); // g
}
{
S *object_6 = nullptr;
{
S("e", "s"); // e
// s
}
{
S *object_8 = nullptr;
}
object_6 = new S(":", "i"); // :
S *object_9 = nullptr;
S *object_10 = new S(":", "o"); // :
delete object_6; // i
{
object_9 = new S("n", "l"); // n
static S object_11("_", "u"); // _
{
S *object_12 = new S("f", "a"); // f
delete object_10; // o
delete new S("u", "n"); // u
// n
}
S object_14("d", "_"); // d
static S object_15("_", "s"); // _
S *object_16 = new S("r", ":"); // r
thread_local S object_17("e", "_"); // e
static S object_18("s", "e"); // s
thread_local S object_19("u", "d"); // u
delete object_9; // l
thread_local S object_20("t", "n"); // t
S *object_21 = new S(":", "n"); // :
delete object_16; // :
delete new S("o", "p"); // o
Solutions 185

// p
S("e", "r"); // e
// r
static S object_24("a", "r"); // a
S *object_25 = nullptr;
object_25 = new S("t", "l"); // t
S *object_26 = nullptr;
S object_27("o", "r"); // o
} // r
// _
{
S *object_28 = new S("i", "x"); // i
delete new S("n", "_"); // n
// _
}
thread_local S object_30("f", "u"); // f
}
} // o

// Main Thread Exit


// u
// n
// d
// _

// Program Exit
// r
// e
// s
// u
// l
// t

// Answer: ranges::in_found_result::operator_in_found_result

You might also like