A Forward Reference in a Field of a Structure

ID Number: Q23470

4.00

MS-DOS

buglist4.00

Question:

Is it legal to use a forward reference in a field of a structure?

The following is an example:

SAMPLE STRUC

FILED1 DB 0

FIELD2 DB 0

FIELDDUP DB TYPE FORWARDREF DUP(0)

FIELD4 DB 0

SAMPLE ENDS

DATA SEGMENT

FORWARDREF DW 0

DATA ENDS

Pass one of the assembler generates one byte of data for FIELDDUP so

the offset for FIELD4 is 3. Pass two corrects this error by generating

2 bytes of data for FIELDDUP, and the offset for FIELD4 reflects this

correction in the code listing, but not in the structure table.

The above code generates the following structure table:

Name Width

Shift

SAMPLE............... 0005

FIELD1............. 0000

FIELD2............. 0001

FILEDDUP........... 0002

FIELD4............. 0003 Should this be offset 4?

If it is not legal to do this, should the assembler generate the

"forward reference not allowed" error message?

Response:

Microsoft has confirmed this to be a problem in Version 4.00. The

problem was corrected in MASM Version 5.00.