Dangling Pointer - Cause of Wild Pointers

Cause of Wild Pointers

Wild pointers are created by omitting necessary initialization prior to first use. Thus, strictly speaking, every pointer in programming languages which do not enforce initialization begins as a wild pointer.

This most often occurs due to jumping over the initialization, not by omitting it. Most compilers are able to warn about this.

int f(int i) { char *dp; /* dp is a wild pointer */ static char *scp; /* scp is not a wild pointer: * static variables are initialized to 0 * at start and retain their values from * the last call afterwards. * Using this feature may be considered bad * style if not commented */ }

Read more about this topic:  Dangling Pointer

Famous quotes containing the word wild:

    The wildest dreams of wild men, even, are not the less true, though they may not recommend themselves to the sense which is most common among Englishmen and Americans to-day. It is not every truth that recommends itself to the common sense. Nature has a place for the wild clematis as well as for the cabbage. Some expressions of truth are reminiscent,—others merely sensible, as the phrase is,—others prophetic.
    Henry David Thoreau (1817–1862)