• xep@fedia.io
    link
    fedilink
    arrow-up
    0
    ·
    7 days ago

    In the WTF case, the reason is because this would allow modification of the const, so it is not allowed.
    From https://en.cppreference.com/w/cpp/language/implicit_conversion

    int main() { const char c = ‘c’; char* pc; char** ppc = &pc; const char** pcc = ppc; // Error: T3 is not the same as cv-unqualified T2, no implicit conversion. *pcc = &c; *pc = ‘C’; // If the erroneous assignment above is allowed, the const object “c” may be modified. }