Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 229593) +++ gcc/fortran/decl.c (working copy) @@ -1293,7 +1293,9 @@ gfc_set_constant_character_len (int len, int slen; gcc_assert (expr->expr_type == EXPR_CONSTANT); - gcc_assert (expr->ts.type == BT_CHARACTER); + + if (expr->ts.type != BT_CHARACTER) + return; slen = expr->value.character.length; if (len != slen) Index: gcc/testsuite/gfortran.dg/pr51993.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr51993.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/pr51993.f90 (working copy) @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/51993 +! Code contributed by Sebastien Bardeau +module mymod + type :: mytyp + character(len=3) :: a = .true. ! { dg-error "convert LOGICAL" } + end type mytyp +end module mymod