https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96859
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #2 from kargl at gcc dot gnu.org --- gfortran appears to be correct. Writing an actual program with your examples, I have program foo print '(I0,1X,I0)', & & merge_bits(32767_2,o'1234567',32767_2), & & ior(iand(32767_2,32767_2),iand(o'1234567',not(32767_2))) print '(I0,1X,I0)', & & merge_bits(o'1234567',32767_2,o'1234567'), & & ior(iand(o'1234567',int(o'1234567',2)),iand(32767_2,not(int(o'1234567',2)))) print '(I0,1X,I0)', & & merge_bits(32767_2,o'1234567',b'010101'), & & ior(iand(32767_2,b'010101'),iand(o'1234567', not(int(b'010101',2)))) print '(I0,1X,I0)', & & merge_bits(32767_2,o'1234567',z'12345678'), & & ior(iand(32767_2,z'12345678'), iand(o'1234567',not(int( z'12345678',2)))) end program foo