Note that there are some explanatory texts on larger screens.

plurals
  1. USKranar
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. CO@John I disagree. You may not assign an invalid pointer value. You may store an invalid pointer value because you just used delete... but you may not use such an invalid value in any operation, be it copying, assigning, dereferencing, arithmetic, anything... since foo is an invalid pointer value, using it in an assignment results in undefined behavior, granted that most compilers won't complain and most runtimes won't care either.
      singulars
    2. CO@John: 5.7 paragraph 5 specifies that unless the result of performing addition between a pointer and an integral type results in a pointer to the same array object or one past the last element of the array object, then the result is undefined. Hence p += 4 when p is an invalid pointer value results in undefined behavior even for a complete type. I'm telling you... this is a tricky language and it requires a very fine understanding to know whether something is valid or not. That's just an unfortunate consequence of C++.
      singulars
    3. CO@John: 3.7.3.2.4 which as you correctly mention is about deallocation functions, is specifying specifically what the consequence of using such a deallocation function on a valid pointer value is. The consequence it is specifying is that if the valid pointer value being deallocated is non-null, then that pointer value no longer becomes valid, and hence, any use of said invalid pointer value results in undefined behavior. It does not mean simply that invalid pointer values can not be deallocated, it is making a general statement about the consequence of deallocating a valid pointer value.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload