8 comments

  • pjmlp 56 minutes ago
    2018, and some of the comments are already outdated, SPARK 2014 is out there with ownership model.
  • glitchc 20 minutes ago
    I don't think GCC is doing something special, rather that -O3 might be optimizing out the subtraction. Try with -O0, I suspect you will get the same result as clang.
  • bryanlarsen 28 minutes ago
    Pointers have provenance, integers don't.
  • hn_submit 37 minutes ago
    Context.
  • spwa4 24 minutes ago
    There is no difference.

    Yes, I'm a C programmer, how did you know?

    • yxhuvud 1 minute ago
      There is a counter example in the OP.
    • Ohentis 15 minutes ago
      It doesn't sound like you are or you would know C doesn't define either precisely enough to make that statement true.
    • Ungh 8 minutes ago
      There's the voice of a C programmer who hasn't used hardware with a different word size to address space...
    • drfloyd51 20 minutes ago
      You should read TFA.
  • stronglikedan 20 minutes ago
    well, their names, for starters...
  • cowlevel 6 minutes ago
    > First, does this C program execute undefined behavior? It does not! Computing out-of-bounds pointers is UB but we are free to do whatever we like with integer-typed values that were derived from pointers. Second, does the C standard mandate the behavior that we saw here? It does not!

    Behaviour that is not defined is undefined behaviour. Integer to pointer conversion is IDB, which is the same as UB except that a conforming compiler documents what could happen. I believe it's typically documented as unpredictable, so the same as plain UB.

    • saagarjha 5 minutes ago
      No, these are different things.