http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59604
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 --- (In reply to Thomas Koenig from comment #1) > TRANSFER gets this right. It is unclear what you mean here. A simplified program that removes the complication of the IO and ISO C binding is program test if (int(z'FFFFFFFF') /= -1) call abort end program test % gfc4x -o z -fno-range-check -fdump-tree-original a.f90 % ./z Program aborted. Backtrace: #0 0x4807A01C #1 0x4807B8CF #2 0x48134C17 #3 0x8048792 in MAIN__ at a.f90:0 Abort (core dumped) %cat a.f90.003t.orginal test () { _gfortran_abort (); L.1:; } main (integer(kind=4) argc, character(kind=1) * * argv) { static integer(kind=4) options.0[9] = {68, 1023, 0, 0, 1, 1, 0, 0, 31}; _gfortran_set_args (argc, argv); _gfortran_set_options (9, &options.0[0]); test (); return 0; } I believe the problem lies in gfc_simplify_int. From what I can tell, there is never a conversion of a boz to an integer, until we reach code generation. The call chain is gfc_simplify_int -> simplify->intconv -> gfc_convert_constant -> gfc_int2int. By the time we reach gfc_int2int, the boz should have been converted to the integer, but isn't. Now, if we compare gfc_simplify_int to gfc_simplify_real, we see in gfc_simplify_real, if (convert_boz (e, kind) == &gfc_bad_expr) return &gfc_bad_expr; where convert_boz will do an explicit conversion of a boz to a real type. There isn't a similar functionality for integer.