Article - CS258897
ObjectAda sometimes generates invalid code to store a bit field record compoment
Modified: 18-Mar-2017
Applies To
- ObjectAda 9.2
Description
- Values of enumeration types in executable are wrong
- Record components have the wrong value
- In some cases, ObjectAda generates the wrong instructions:
- Record components less than 16 bits that occupy more than one byte of memory
- Problem seems to occur most frequently if data type is an enumeration type
- Example of source code that exposes the problem:
-
package bug_pkg is type T1 is (e1,e2,e3,e4,e5); type rec is record b : boolean; z : T1; end record; for rec use record b at 0 range 0..5; z at 0 range 6..8; end record; type ptr is access all T1; procedure test (r : in out rec; p : ptr; b : boolean); end; package body bug_pkg is procedure test (r : in out rec; p : ptr; b : boolean) is begin r := (b,p.all); end; end; - Incorrect code generated when compiling source code above:
-
The code generated to store the record component r.z is as follows: MOV BH, [EAX+0] <--------------- Value loaded into BH CMP BH, 4 JA SHORT L7 SHL BX, 6 <-- Incorrectly assumes value was loaded into BL AND BX, 448 AND WORD PTR [EBP-4], 65087 OR [EBP-4], BX ; DY4 MOV EBX, [EBP+8] ; r MOV CX, [EBP-4] ; DY4 MOV [EBX+0], CX
This is a printer-friendly version of Article 258897 and may be out of date. For the latest version click CS258897