Converting 'String' Type in swift to 'const char *' in cpp

I have the below code where my swift code calls a cpp function. In this the swift calls a cpp function and passes a swift 'String' as argument to it, which is then received in the cpp code as 'const char *'. This conversion works without any errors. Is this a documented behaviour in cpp-swift interop and is this safe to use?

Swift side:

internal static func CharCheck (pSentence: String) -> Void 
{
TWSoundLogic.CharacterSoundCount (pSentence)
}

In the C++ side,

void TWSoundLogic::CharacterSoundCount (const char * pSentence) 
{
..
}

However, on returning a String type from a swift function and trying to receive it as a const char* in c++, it gives an error in cpp No viable conversion from 'swift::String' to 'const char *' . Why does it not allow to return, but it allows to pass as argument? Can someone explain this behaviour?

Converting 'String' Type in swift to 'const char *' in cpp
 
 
Q