UE4 FString.FindChar doesnt function as stated

UE4F String.FindChar(‘a’, i);
In the describtion of the above function i which is an int32 will ahve its value replaced by the position of the char in case the char is found , if not the value will not change.

The bug is that if the char is not found , the value do change to -1 and this is because the implementation of the function is as follows:

FORCEINLINE bool FindChar( TCHAR InChar, int32& Index ) const
{
	return Data.Find(InChar, Index);
}

Where Data.Find is implemented as :

FORCEINLINE bool Find(const ElementType& Item, int32& Index) const
	{
		Index = this->Find(Item);
		return Index != INDEX_NONE;
	}

Where we can see that the Index equals the Find(Item) that can equal(incase not found) to INDEX_NONE which is a define of value -1 , this was tested and its true that i is replaced with -1 where it value should remain unchanged if the function returns false.

Hi,

I’ve fixed the FindChar comment, and also in FindLastChar. Thanks for reporting it!

That fix can be found along with other changes here:

https://github.com/EpicGames/UnrealEngine/commit/5db2bff2faaeb4dee8bf64263566cbaf4aa8333a

Steve