I know the difference between const and constexpr. One of them is a compilation time constant, and the other is compilation time or a run-time constant.
However, for an array of characters / strings, I am confused why the compiler complains that one of them is used over the other.
For example, I have:
constexpr char* A[2] = {"....", "....."}; const constexpr char* B[2] = {"....", "....."};
With the declaration "A" I get:
ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
but with the declaration "B" I do not receive any warnings.
Why does the optional constant determinant get rid of the warning? Aren't they both "const char *"? I ask because both are declared using constexpr , which should make it const char* by default?
I would expect A to be fine: S
source share