Content deleted Content added
→Bit fields: Bit fields are also allowed in unions (not that they'd be particularly useful in that case). Tags: Mobile edit Mobile web edit Advanced mobile edit |
Pinkshrimp (talk | contribs) m →Dynamic arrays: Spelling/grammar/punctuation/typographical correction |
||
Line 315:
</syntaxhighlight>
This ensures that further attempts to dereference the pointer, on most systems, will crash the program. If this is not done, the variable becomes a [[dangling pointer]] which can lead to a use-after-free bug. However, if the pointer is a local variable, setting it to {{code|NULL}} does not prevent the program from using other copies of the pointer. Local use-after-free bugs are usually easy for [[static analyzer]]s to recognize. Therefore, this approach is less useful for local pointers and it is more often used with pointers stored in long-living structs. In general though, setting pointers to {{code|NULL}} is good practice {{according to whom|date=August 2020}} as it allows a programmer
Recalling the array example, one could also create a fixed-size array through dynamic allocation:
|