https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85450
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- There are 4 spots, unsigned_type_for breaks for-5.c though. There are several other spots that do use signed_type_for instead, so following works for the testsuite: --- gcc/omp-expand.c.jj 2018-04-16 20:35:14.663558320 +0200 +++ gcc/omp-expand.c 2018-04-19 17:14:13.267424165 +0200 @@ -3501,7 +3501,12 @@ expand_omp_for_static_nochunk (struct om t = fold_convert (itype, s0); t = fold_build2 (MULT_EXPR, itype, t, step); if (POINTER_TYPE_P (type)) - t = fold_build_pointer_plus (n1, t); + { + t = fold_build_pointer_plus (n1, t); + if (!POINTER_TYPE_P (TREE_TYPE (startvar)) + && TYPE_PRECISION (TREE_TYPE (startvar)) > TYPE_PRECISION (type)) + t = fold_convert (signed_type_for (type), t); + } else t = fold_build2 (PLUS_EXPR, type, t, n1); t = fold_convert (TREE_TYPE (startvar), t); @@ -3515,7 +3520,12 @@ expand_omp_for_static_nochunk (struct om t = fold_convert (itype, e0); t = fold_build2 (MULT_EXPR, itype, t, step); if (POINTER_TYPE_P (type)) - t = fold_build_pointer_plus (n1, t); + { + t = fold_build_pointer_plus (n1, t); + if (!POINTER_TYPE_P (TREE_TYPE (startvar)) + && TYPE_PRECISION (TREE_TYPE (startvar)) > TYPE_PRECISION (type)) + t = fold_convert (signed_type_for (type), t); + } else t = fold_build2 (PLUS_EXPR, type, t, n1); t = fold_convert (TREE_TYPE (startvar), t); @@ -4000,7 +4010,12 @@ expand_omp_for_static_chunk (struct omp_ t = fold_convert (itype, s0); t = fold_build2 (MULT_EXPR, itype, t, step); if (POINTER_TYPE_P (type)) - t = fold_build_pointer_plus (n1, t); + { + t = fold_build_pointer_plus (n1, t); + if (!POINTER_TYPE_P (TREE_TYPE (startvar)) + && TYPE_PRECISION (TREE_TYPE (startvar)) > TYPE_PRECISION (type)) + t = fold_convert (signed_type_for (type), t); + } else t = fold_build2 (PLUS_EXPR, type, t, n1); t = fold_convert (TREE_TYPE (startvar), t); @@ -4014,7 +4029,12 @@ expand_omp_for_static_chunk (struct omp_ t = fold_convert (itype, e0); t = fold_build2 (MULT_EXPR, itype, t, step); if (POINTER_TYPE_P (type)) - t = fold_build_pointer_plus (n1, t); + { + t = fold_build_pointer_plus (n1, t); + if (!POINTER_TYPE_P (TREE_TYPE (startvar)) + && TYPE_PRECISION (TREE_TYPE (startvar)) > TYPE_PRECISION (type)) + t = fold_convert (signed_type_for (type), t); + } else t = fold_build2 (PLUS_EXPR, type, t, n1); t = fold_convert (TREE_TYPE (startvar), t); Though, I think it would be better to replace most of the signed_type_for related to pointer types to unsigned_type_for. Not something I have time for right now though.