# \[Bug Report\] Clang 3.5 compilation error with -Werror and -Wshado

**URL:** <https://forums.unrealengine.com/t/bug-report-clang-3-5-compilation-error-with-werror-and-wshado/329841>\
**Category:** Platform & Builds\
**Tags:** compilation, clang, Linux, unreal-engine, question, CPP\
**Created:** [August 25, 2015, 10:26am UTC](https://forums.unrealengine.com/t/bug-report-clang-3-5-compilation-error-with-werror-and-wshado/329841 "2015-08-25T10:26:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e955dac61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e955dac61](https://forums.unrealengine.com/u/anonymous_user_e955dac61)\
**Post date:** [August 25, 2015, 10:26am UTC](https://forums.unrealengine.com/t/bug-report-clang-3-5-compilation-error-with-werror-and-wshado/329841/1 "2015-08-25T10:26:11Z")

</div>

It seems Clang is a little rabid in terms of variable naming - because “-Wshadow” is set, attempting to compile a C++ class on Linux using Clang 3.5 results in a warning when a function parameter has the same name as data member. As the flag “-Werror” is also set, this warning gets promoted to a full-blown error and interrupts the build.

Dropping “-Werror” from the compilation arguments should theoretically make these issues a visual log annoyance instead of a blocking issue. GCC has had the same issue as a bug report, but has apparently fixed it.

[https://gcc.gnu.org/bugzilla/show\_bug.cgi?id=57709](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57709)

The provided sample code below compiles fine on Windows 7 using Visual Studio 2013 Community, but fails with the following error on Linux Mint 17.2, using Qt Creator and Clang 3.5.

Sample code:

```
#pragma once

#include "GameProject.h"
#include "MemoryElement.generated.h"
/**
 * 
 */
USTRUCT()
struct GAMEPROJECT_API FMemoryElement
{
	GENERATED_USTRUCT_BODY();
public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Memory")
		FString KeyName;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Memory")
		FString Data;

	FMemoryElement()
	{
		KeyName = "";
		Data = "";
	}

	FMemoryElement(FString KeyName, FString Data)
	{
		this->KeyName = KeyName;
            this->Data = Data;
	}
};

```

Compilation Error:

```
In file included from /home//Programming/Unreal Projects/GameProject 4.8/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/UE4Editor/Inc/GameProject/GameProject.generated.cpp:9:
In file included from ../../../Unreal Projects/GameProject 4.8/Intermediate/Build/Linux/x86_64-unknown-linux-gnu/UE4Editor/Inc/GameProject/GameProject.generated.dep.h:21:
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:27:25: error: declaration shadows a field of 'FMemoryElement' [-Werror,-Wshadow]
        FMemoryElement(FString KeyName, FString Data)
                               ^
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:16:11: note: previous declaration is here
                FString KeyName;
                        ^
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:27:42: error: declaration shadows a field of 'FMemoryElement' [-Werror,-Wshadow]
        FMemoryElement(FString KeyName, FString Data)
                                                ^
../../../Unreal Projects/GameProject 4.8/Source/GameProject/Dialogue/MemoryElement.h:19:11: note: previous declaration is here
                FString Data;
                        ^

```

While workarounds are available (renaming member variables to have a trailing underscore, renaming the function parameter), it is a common idiom to give function parameters the same name as the variable they initialize or affect.

```
Distro: Linux Mint 17.2
Compiler: Clang 3.5
IDE: Qt Creator
Unreal Engine: 4.8.3 (Github 4.8 branch source build)

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e955dac61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e955dac61](https://forums.unrealengine.com/u/anonymous_user_e955dac61)\
**Post date:** [August 26, 2015, 6:34pm UTC](https://forums.unrealengine.com/t/bug-report-clang-3-5-compilation-error-with-werror-and-wshado/329841/2 "2015-08-26T18:34:51Z")

</div>

Continuing this on the forums, since it seems to be a quirk with UBT.

> **[\[Linux\] Clang 3.5 compilation error with -Werror and -Wshado](https://forums.unrealengine.com/showthread.php?81958-Linux-Clang-3-5-compilation-error-with-Werror-and-Wshado)**
>
> This is a copied post from answerhub - I’m having issues with Clang compilation on Linux, as described below. Any help would be greatly appreciated! It seems Clang is a little rabid in terms of variable naming - because “-Wshadow” is set,...
