BUG: C1001 ICE If Compiling MFC Applications with /vmg Option

ID: Q126844

1.00 1.50 1.51 1.52 WINDOWS kbtool kbbuglist

The information in this article applies to:

SYMPTOMS

Compiling an MFC application with the /vmg compiler option may result in the following warning and fatal compiler error:

        warning C4759: segment lost in conversion

        fatal error C1001: INTERNAL COMPILER ERROR
                    ( compiler file 'gencode.c', line 408 )

CAUSE

Each entry in an MFC message map specifies a member function to be called in response to a certain message. To accomplish this, the message map facility uses pointers to member functions.

Depending on the inheritance model used by each class, the compiler represents pointers to member functions differently. You can specify the way in which the compiler will represent pointers to member functions with the /vmb (Best-case always) and the /vmg (General-purpose always) C++ compiler options.

If you specify the /vmg (General-purpose always) option, and specify any inheritance model other than /vms (for single inheritance), the C1001 error will result.

RESOLUTION

1. Use the /vmb (Best-case always) C++ compiler option, which is the

   default option, for MFC applications. If you must use the /vmg
   (General-purpose always) option, use it with /vms (single
   inheritance) for MFC applications.

   - or -

2. Use #pragma pointers_to_members( pointer-declaration,
                                    [most-general-representation] )

   where pointer-declaration could be one of the following:

    - full_generality
    - best_case

   and the [most-general-representation] could be one of:

    - single_inheritance
    - multiple_inheritance
    - virtual_inheritance

   The equivalent compiler option for full_generality is /vmg and
   option for best_case is /vmb. The equivalent of the
   single_inheritance is /vms, the multiple_inheritance is /vmm, and
   the virtual_inheritance is /vmvand, which is the default option used
   by the compiler for both full_generality and best_case.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

If you specify the /vmb (Best-case always) C++ compiler option, which is the default, the compiler uses the smallest possible representation of each pointer, and will generate the smallest amount of code required to operate on the pointer for each kind of inheritance.

If you specify the /vmg (General-purpose always) option, you must also specify an option to indicate the inheritance model of the classes. This can be one of three options: /vms (single inheritance), /vmm (multiple inheritance) or /vmv (virtual inheritance or point to any class). The default general-purpose representation is /vmv. In other words, specifying /vmg by itself indicates to the compiler that you are using the /vmv representation. This will result in the C1001 error.

Additional reference words: 8.00 8.00c 1.00 1.50 1.51 1.52 KBCategory: kbtool kbbuglist KBSubCategory: CPPIss Keywords : kb16bitonly

Last Reviewed: July 23, 1997