←back to thread

498 points azhenley | 3 comments | | HN request time: 0.23s | source
1. WalterBright ◴[] No.45774916[source]
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?
replies(2): >>45774963 #>>45774985 #
2. taf2 ◴[] No.45774963[source]
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.
3. wicharek ◴[] No.45774985[source]
Yes, because line 3 would implicitly be: const int * p