Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space INSDEVEL and version 7.5.4

In this section:

Table of Contents
maxLevel1
minLevel1

Overview

This error is generated when a call is made through an uninitialized function pointer. 

Excerpt

Scroll Table Layout
sortDirectionASC
repeatTableHeadersdefault
widths10%,60%,10%,10%,10%
sortByColumn1
sortEnabledfalse
cellHighlightingtrue

CodeDescriptionEnabledReportedPlatform
FUNC_UNINIT_PTR

Function pointer is uninitialized

(tick)RuntimeWindows/Unix


Problem

The following code attempts to call a function through a pointer that has not been set:

Code Block
languagecpp
themeEclipse
linenumberstrue
/*
 * File: funcuptr.c
 */
main()
{
	void (*a)();

	a();
	return (0);
}

Diagnosis at Runtime

Code Block
languagetext
linenumberstrue
[funcuptr.c:8] **FUNC_UNINIT_PTR**
>>		 a();
Function pointer is uninitialized: a
Stack trace where the error occurred:
		main() funcuptr.c, 8
**Memory corrupted. Program may crash!!**
  • Line 2: Source line at which the problem was detected.
  • Line 3: Description of the problem and the expression that is in error.
  • Line 5: Stack trace showing the function call sequence leading to the error.
  • Line 6: Informational message indicating that a serious error has occurred which may cause the program to crash.

Repair

This problem normally occurs because some assignment statement has been omitted from the code. The current example can be fixed as follows:

Code Block
languagecpp
themeEclipse
linenumberstrue
extern void myfunc();
main()
{
	void (*a)();
	a = myfunc;
	a();
}