c++: Avoid UB in signed shift [PR 98625]

Nathan Sidwell nathan@acm.org
Wed Jan 20 17:23:36 GMT 2021


Thanks Jakub & Martin for unconfusing me about where the UB was!

I'd forgotten that left	shifting a negative value is UB	until C++20.
Insert some casts to do	unsigned shifts.

	PR c++/98625
	gcc/cp/
         * module.cc (bytes_in::i, bytes_in::wi): Avoid left shift of
         signed type.

-- 
Nathan Sidwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr98625.diff
Type: text/x-patch
Size: 944 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210120/2b2beda4/attachment-0001.bin>


More information about the Gcc-patches mailing list