# Uninitialized bool serialized and used

**URL:** <https://forums.unrealengine.com/t/uninitialized-bool-serialized-and-used/295639>\
**Category:** Platform & Builds\
**Tags:** bool, serialization, unreal-engine, bug-report, feedback, question\
**Created:** [October 8, 2014, 9:05pm UTC](https://forums.unrealengine.com/t/uninitialized-bool-serialized-and-used/295639 "2014-10-08T21:05:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rejecht\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rejecht\_1](https://forums.unrealengine.com/u/rejecht_1)\
**Post date:** [October 8, 2014, 9:05pm UTC](https://forums.unrealengine.com/t/uninitialized-bool-serialized-and-used/295639/1 "2014-10-08T21:05:49Z")

</div>

**Source File:**  
/Engine/Source/Runtime/NetworkFileSystem/Private/NetworkFileServerConnection.cpp

**Description:**  
bReadOnly has automatic storage duration but is not initialized, then gets serialized and used in a call to SetReadOnly.

**Reference:**  
[https://github.com/EpicGames/UnrealEngine/blob/69b5693c869697b828e1f2c24004ff1481b5fb98/Engine/Source/Runtime/NetworkFileSystem/Private/NetworkFileServerConnection.cpp#L557](https://github.com/EpicGames/UnrealEngine/blob/69b5693c869697b828e1f2c24004ff1481b5fb98/Engine/Source/Runtime/NetworkFileSystem/Private/NetworkFileServerConnection.cpp#L557)

**Reference Line:** 557

**Notes:** Found with the aid of static program analysis (Cppcheck).

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [October 10, 2014, 3:24pm UTC](https://forums.unrealengine.com/t/uninitialized-bool-serialized-and-used/295639/2 "2014-10-10T15:24:51Z")

</div>

Hi rejecht,

Is this causing any errors or crashes for you? If so, could you provide any relevant log files or callstacks?

---

<div class="post-metadata">

**Author:** ![rejecht\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rejecht\_1](https://forums.unrealengine.com/u/rejecht_1)\
**Post date:** [October 12, 2014, 3:24pm UTC](https://forums.unrealengine.com/t/uninitialized-bool-serialized-and-used/295639/3 "2014-10-12T15:24:36Z")

</div>

Hi ,

You may dismiss the original bug report. It turns out the classes do the right thing after a closer look at what FArchive does, however, the C++ code tells me the wrong thing semantically.

If the code had read…  
In \>\> bReadOnly;

…it would be clear to a C++ programmer that bReadOnly gets initialized at that point.

The code instead reads…  
In \<\< bReadOnly;

Standard C++ language semantics for the above means to take the value of bReadOnly (uninitialized in this case) and write it to In. Since that didn’t make much sense, I had a closer look at FArchive, which rewrites the meaning of the operator \<\<.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [October 13, 2014, 8:00pm UTC](https://forums.unrealengine.com/t/uninitialized-bool-serialized-and-used/295639/4 "2014-10-13T20:00:23Z")

</div>

Hi rejecht,

I noticed that oddity as well when I was looking at the code in NetworkFileServerConnection.cpp. Unfortunately I do not think this is something that we will make clearer at some point.
