https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96859
--- Comment #4 from zhen...@compiler-dev.com --- (In reply to kargl from comment #2) > 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 I compiled your code with gfortran-10, getting result: -1 -1 -1 -1 -18057 -18057 -129 -129 The right one should be: 32767 32767 32767 32767 14711 14711 32639 32639