C9201003: No C4098 for a Void Function Returning an Address

ID Number: Q80102

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00a buglist6.00ax fixlist7.00

Summary:

SYMPTOMS

In the Microsoft C Compiler versions 6.0, 6.0a, and 6.0ax, and in

the Microsoft QuickC Compiler versions 2.5 and 2.51, if a function

declared void returns the address of a variable, the compiler may

not generate the following warning message:

warning C4098: void function returning a value

If the return value of the function is then used as an rvalue, the

following warning message may be generated:

warning C4053: at least one void operand

RESOLUTION

If a C4053 error is generated when a function is used even though

the function itself compiled without errors, check to see that the

function is declared with a return type matching the type of the

value actually returned.

STATUS

Microsoft has confirmed this to be a problem in C versions 6.0,

6.0a, and 6.0ax, and in QuickC versions 2.5 and 2.51 (buglist2.50

and buglist2.51). This problem was corrected in C/C++ version 7.0.

More Information:

The sample code below illustrates a function that will compile with no

warnings or errors. Since the function actually returns the address of

an int, a C4098 warning should be given.

Sample Code

-----------

/* Compile options needed: /c

*/

void t(int *s)

{

return s;

}

Additional reference words: 2.50 2.51 6.00 6.00a 6.00ax