ID Number: Q66217
6.00 6.00a 6.00ax | 6.00 6.00a
MS-DOS | OS/2
buglist6.00 buglist6.00a buglist6.00ax fixlist7.00
SYMPTOMS
In Microsoft C versions 6.0, 6.0a, and 6.0ax, in certain cases, the
use of the Pascal modifier (_pascal) on a function will incorrectly
generate the following warning:
warning C4059: segment lost in conversion
The problem occurs in small (/AS) or medium (/AM) memory model
if you call a function that takes a structure as an argument with a
procedure that returns a structure and is declared with the Pascal
modifier.
RESOLUTION
The warning goes away if you do one of the following:
- Compile with the /qc (quick compile) option.
- Remove the _pascal modifier.
- Compile in compact (/AC) or large (/AL) memory model.
STATUS
Microsoft has confirmed this to be a problem in C versions 6.0,
6.0a, and 6.0ax. This problem was corrected in C/C++ version 7.0.
More Information:
The sample code below illustrates this problem. A C4059 warning should
not be generated in this case.
Although the warning is intended to flag a possible problem, the
warning is not valid and the compiler generates the correct code for
the program. Note that the code is incorrect only if /Au or /Aw is
used.
Sample Code
-----------
/* Compile options needed: /c /W2
*/
#include <stdio.h>
struct s {int i,j,k,l; };
struct s _pascal func1(void)
{
struct s b = {1, 2, 3, 4};
return b;
}
void func2(struct s b)
{
printf("%d %d %d %d\n", b.i, b.j, b.k, b.l);
}
void main () {
func2(func()); /* this line causes warning C4059 */
}
Additional reference words: 6.00 6.00a 6.00ax