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] |
In full warning mode, when an unchecked conversion is applied to types of different sizes, the compiler issues a warning describing the effects of the conversion on the additional or missing bits. When the source is smaller than the target, it was issuing a specific warning if the target is of a discrete type but, when the source is larger than the target, it wasn't doing the same if the source is of a discrete type. The compiler must issue the following warnings with -gnatf: ucw.ads:12:03: warning: types for unchecked conversion have different sizes ucw.ads:12:03: warning: size of "REC" is 16, size of "INTEGER" is 32 ucw.ads:12:03: warning: target value will include 16 undefined high order bits ucw.ads:13:03: warning: types for unchecked conversion have different sizes ucw.ads:13:03: warning: size of "INTEGER" is 32, size of "REC" is 16 ucw.ads:13:03: warning: 16 high order bits of source will be ignored on with Unchecked_Conversion; package UCW is type Int8_t is mod 2**8; type Rec is record I1 : Int8_t; I2 : Int8_t; end record; function C1 is new Unchecked_Conversion (Source => Rec, Target => Integer); function C2 is new Unchecked_Conversion (Source => Integer, Target => Rec); end UCW; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-05-22 Eric Botcazou <ebotcazou@adacore.com> * sem_ch13.adb (Validate_Unchecked_Conversions): Also issue specific warning for discrete types when the source is larger than the target.
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] |