This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
The compiler blows up on an object of a derived array type where the index is of an enumeration type with specified representation and the component is of a floating-point type. In this case, the derived type and its parent type were not considered to have the same representation, because the component size of the parent was not getting set by the front end's layout phase (only array types with discrete components were set), whereas the derived type had its component size set properly in Freeze_Type (because its parent type was treated as packed due to the nonstandard representation of its index). The layout for array types now sets the component size in the case of arrays with components of any scalar type. This change also helps avoid expensive (and unnecessary) representation conversions between derived array types of this kind. The package init_scalar_bug.adb, given below, must compile with only the following warning output (or quietly with -gnatws): init_scalar_bug.adb:13:11: warning: default initialization of "Result" may modify overlaid storage init_scalar_bug.adb:13:11: warning: use pragma Import for "Result" to suppress initialization (RM B.1(24)) pragma Initialize_Scalars; package Float_Arr_Pkg is type Repped_Enum is (Enum_1, Enum_2, Enum_3); for Repped_Enum use (Enum_1 => 1, Enum_2 => 2, Enum_3 => 3); type Float_Array is array (Repped_Enum) of Float; end Float_Arr_Pkg; with System; package Init_Scalar_Bug is procedure Proc (Addr : System.Address); end Init_Scalar_Bug; pragma Initialize_Scalars; with Float_Arr_Pkg; package body Init_Scalar_Bug is type New_Float_Array is new Float_Arr_Pkg.Float_Array; procedure Proc (Addr : System.Address) is Result : New_Float_Array; for Result use at Addr; begin null; end Proc; end Init_Scalar_Bug; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-17 Gary Dismukes <dismukes@adacore.com> * layout.adb (Layout_Type): Broaden test for setting an array type's Component_Size to include all scalar types, not just discrete types (components of real types were missed). * sem_ch3.adb (Constrain_Index): Add missing setting of First_Literal on the itype created for an index (consistent with Make_Index and avoids possible Assert_Failures).
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |