For the avoidance of doubt the language itself permits this.
Essentially though the static analyser you are using forbids this because std::string contains a constructor so the statement actually "does something".
Therefore it needs to be inside a function, not at global scope.
On the other hand,
const char* VAR = "HELLO_WORLD";
is emitted, since that's no more than an assignment of a read-only const char[] literal to an appropriate pointer.
For the avoidance of doubt the language itself permits this.
Essentially though the static analyser you are using forbids this because
std::string
contains a constructor so the statement actually "does something".Therefore it needs to be inside a function, not at global scope.
On the other hand,
is emitted, since that's no more than an assignment of a read-only
const char[]
literal to an appropriate pointer.