Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm curious where this fits in with single assignment semantics:

    int x = 3;
    x = 4; // error!
    int* p = &x;
    *p = 4; // is that an error?


At least with clang it's a warning:

    f.c:4:8: warning: initializing 'int *' with an expression of type 'const int     *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    4 |   int* p = &x;
      |        ^   ~~
    1 warning generated.


Yes, because line 3 would implicitly be: const int * p




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: