When are you trying to make this call and how are you going about checking it? Also, are you sure that the PlayerController is being set correctly in your GameMode?
I tried testing by making a custom playercontroller, a custom actor, and a custom gamemode. In the gamemode I set the default playercontroller to the custom one. In the custom actor I made the cast to the playercontroller in beginplay and then used an if check to see if I should print a log statement based on if the casted variable was null or not. This was the syntax for that.
Found the solution, I was calling UGameplayStatics::GetPlayerController(GetWorld(), 0) in an UBject, where GetWrold() is undifined.
It must be called from an actor.
To see an example, create a new C++ project with the Third Person Game template and take a look at the projectnameGameMode.cpp class generated by the template. It’ll show here, on line 13, how to set the default pawn class. You can do a similar thing to set the default playercontroller by using PlayerContollerClass instead of DefaultPawnClass.