public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR26415 UBSAN: vms-misc.c:636 left shift cannot be represented
@ 2020-08-26 13:45 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-08-26 13:45 UTC (permalink / raw)
  To: binutils

An unsigned short value is promoted to int, thus triggering UB on a
left shift of a positive value that results in a negative int.

	PR 26415
	* vms-misc.c (vms_time_t_to_vms_time): Don't use unsigned short vars.

diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c
index d040c79de1..0826456ef0 100644
--- a/bfd/vms-misc.c
+++ b/bfd/vms-misc.c
@@ -592,8 +592,8 @@ vms_time_to_time_t (unsigned int hi, unsigned int lo)
 void
 vms_time_t_to_vms_time (time_t ut, unsigned int *hi, unsigned int *lo)
 {
-  unsigned short val[4];
-  unsigned short tmp[4];
+  unsigned int val[4];
+  unsigned int tmp[4];
   unsigned int carry;
   int i;
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-26 13:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 13:45 PR26415 UBSAN: vms-misc.c:636 left shift cannot be represented Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).