Uninitialized bool serialized and used

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

Reference Line: 557

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

Hi rejecht,

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

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 <<.

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.