int main()
{
const char c = ‘c’;
char* pc;
char** ppc = &pc;
const char** pcc = ppc; // Error: not the same as cv-unqualified char**, no implicit conversion.
*pcc = &c;
*pc = ‘C’; // If the erroneous assignment above is allowed, the const object “c” may be modified.
}
C when I cast a
char * *to achar * * const: okC when I cast a
char * *to achar * const *: okC when I cast a
char * *to achar const * *: WTFC when I cast a
char * *to achar const * const *: okThe WTF case isn’t allowed because it would allow modification of the const. From https://en.cppreference.com/w/cpp/language/implicit_conversion
Please stop, I have CPTSD.