[gcc(refs/users/mikael/heads/refactor_descriptor_v07)] Application modifications sources générées

Mikael Morin mikael@gcc.gnu.org
Sun Jun 29 13:43:41 GMT 2025


https://gcc.gnu.org/g:95a8f694329d8d06a3e8be07b421a73f52716324

commit 95a8f694329d8d06a3e8be07b421a73f52716324
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Sun Jun 29 14:36:55 2025 +0200

    Application modifications sources générées

Diff:
---
 libgfortran/generated/all_l1.c           |   35 +-
 libgfortran/generated/all_l16.c          |   35 +-
 libgfortran/generated/all_l2.c           |   35 +-
 libgfortran/generated/all_l4.c           |   35 +-
 libgfortran/generated/all_l8.c           |   35 +-
 libgfortran/generated/any_l1.c           |   35 +-
 libgfortran/generated/any_l16.c          |   35 +-
 libgfortran/generated/any_l2.c           |   35 +-
 libgfortran/generated/any_l4.c           |   35 +-
 libgfortran/generated/any_l8.c           |   35 +-
 libgfortran/generated/bessel_r10.c       |   40 +-
 libgfortran/generated/bessel_r16.c       |   40 +-
 libgfortran/generated/bessel_r17.c       |   40 +-
 libgfortran/generated/bessel_r4.c        |   40 +-
 libgfortran/generated/bessel_r8.c        |   40 +-
 libgfortran/generated/count_16_l.c       |   35 +-
 libgfortran/generated/count_1_l.c        |   35 +-
 libgfortran/generated/count_2_l.c        |   35 +-
 libgfortran/generated/count_4_l.c        |   35 +-
 libgfortran/generated/count_8_l.c        |   35 +-
 libgfortran/generated/cshift0_c10.c      |   61 +-
 libgfortran/generated/cshift0_c16.c      |   61 +-
 libgfortran/generated/cshift0_c17.c      |   61 +-
 libgfortran/generated/cshift0_c4.c       |   61 +-
 libgfortran/generated/cshift0_c8.c       |   61 +-
 libgfortran/generated/cshift0_i1.c       |   61 +-
 libgfortran/generated/cshift0_i16.c      |   61 +-
 libgfortran/generated/cshift0_i2.c       |   61 +-
 libgfortran/generated/cshift0_i4.c       |   61 +-
 libgfortran/generated/cshift0_i8.c       |   61 +-
 libgfortran/generated/cshift0_r10.c      |   61 +-
 libgfortran/generated/cshift0_r16.c      |   61 +-
 libgfortran/generated/cshift0_r17.c      |   61 +-
 libgfortran/generated/cshift0_r4.c       |   61 +-
 libgfortran/generated/cshift0_r8.c       |   61 +-
 libgfortran/generated/cshift1_16.c       |   62 +-
 libgfortran/generated/cshift1_16_c10.c   |   78 +-
 libgfortran/generated/cshift1_16_c16.c   |   78 +-
 libgfortran/generated/cshift1_16_c17.c   |   78 +-
 libgfortran/generated/cshift1_16_c4.c    |   78 +-
 libgfortran/generated/cshift1_16_c8.c    |   78 +-
 libgfortran/generated/cshift1_16_i1.c    |   78 +-
 libgfortran/generated/cshift1_16_i16.c   |   78 +-
 libgfortran/generated/cshift1_16_i2.c    |   78 +-
 libgfortran/generated/cshift1_16_i4.c    |   78 +-
 libgfortran/generated/cshift1_16_i8.c    |   78 +-
 libgfortran/generated/cshift1_16_r10.c   |   78 +-
 libgfortran/generated/cshift1_16_r16.c   |   78 +-
 libgfortran/generated/cshift1_16_r17.c   |   78 +-
 libgfortran/generated/cshift1_16_r4.c    |   78 +-
 libgfortran/generated/cshift1_16_r8.c    |   78 +-
 libgfortran/generated/cshift1_4.c        |   62 +-
 libgfortran/generated/cshift1_4_c10.c    |   78 +-
 libgfortran/generated/cshift1_4_c16.c    |   78 +-
 libgfortran/generated/cshift1_4_c17.c    |   78 +-
 libgfortran/generated/cshift1_4_c4.c     |   78 +-
 libgfortran/generated/cshift1_4_c8.c     |   78 +-
 libgfortran/generated/cshift1_4_i1.c     |   78 +-
 libgfortran/generated/cshift1_4_i16.c    |   78 +-
 libgfortran/generated/cshift1_4_i2.c     |   78 +-
 libgfortran/generated/cshift1_4_i4.c     |   78 +-
 libgfortran/generated/cshift1_4_i8.c     |   78 +-
 libgfortran/generated/cshift1_4_r10.c    |   78 +-
 libgfortran/generated/cshift1_4_r16.c    |   78 +-
 libgfortran/generated/cshift1_4_r17.c    |   78 +-
 libgfortran/generated/cshift1_4_r4.c     |   78 +-
 libgfortran/generated/cshift1_4_r8.c     |   78 +-
 libgfortran/generated/cshift1_8.c        |   62 +-
 libgfortran/generated/cshift1_8_c10.c    |   78 +-
 libgfortran/generated/cshift1_8_c16.c    |   78 +-
 libgfortran/generated/cshift1_8_c17.c    |   78 +-
 libgfortran/generated/cshift1_8_c4.c     |   78 +-
 libgfortran/generated/cshift1_8_c8.c     |   78 +-
 libgfortran/generated/cshift1_8_i1.c     |   78 +-
 libgfortran/generated/cshift1_8_i16.c    |   78 +-
 libgfortran/generated/cshift1_8_i2.c     |   78 +-
 libgfortran/generated/cshift1_8_i4.c     |   78 +-
 libgfortran/generated/cshift1_8_i8.c     |   78 +-
 libgfortran/generated/cshift1_8_r10.c    |   78 +-
 libgfortran/generated/cshift1_8_r16.c    |   78 +-
 libgfortran/generated/cshift1_8_r17.c    |   78 +-
 libgfortran/generated/cshift1_8_r4.c     |   78 +-
 libgfortran/generated/cshift1_8_r8.c     |   78 +-
 libgfortran/generated/eoshift1_16.c      |   62 +-
 libgfortran/generated/eoshift1_4.c       |   62 +-
 libgfortran/generated/eoshift1_8.c       |   62 +-
 libgfortran/generated/eoshift3_16.c      |   80 +-
 libgfortran/generated/eoshift3_4.c       |   80 +-
 libgfortran/generated/eoshift3_8.c       |   80 +-
 libgfortran/generated/findloc0_c10.c     |  109 +--
 libgfortran/generated/findloc0_c16.c     |  109 +--
 libgfortran/generated/findloc0_c17.c     |  109 +--
 libgfortran/generated/findloc0_c4.c      |  109 +--
 libgfortran/generated/findloc0_c8.c      |  109 +--
 libgfortran/generated/findloc0_i1.c      |  109 +--
 libgfortran/generated/findloc0_i16.c     |  109 +--
 libgfortran/generated/findloc0_i2.c      |  109 +--
 libgfortran/generated/findloc0_i4.c      |  109 +--
 libgfortran/generated/findloc0_i8.c      |  109 +--
 libgfortran/generated/findloc0_r10.c     |  109 +--
 libgfortran/generated/findloc0_r16.c     |  109 +--
 libgfortran/generated/findloc0_r17.c     |  109 +--
 libgfortran/generated/findloc0_r4.c      |  109 +--
 libgfortran/generated/findloc0_r8.c      |  109 +--
 libgfortran/generated/findloc0_s1.c      |  109 +--
 libgfortran/generated/findloc0_s4.c      |  109 +--
 libgfortran/generated/findloc1_c10.c     |  116 +--
 libgfortran/generated/findloc1_c16.c     |  116 +--
 libgfortran/generated/findloc1_c17.c     |  116 +--
 libgfortran/generated/findloc1_c4.c      |  116 +--
 libgfortran/generated/findloc1_c8.c      |  116 +--
 libgfortran/generated/findloc1_i1.c      |  116 +--
 libgfortran/generated/findloc1_i16.c     |  116 +--
 libgfortran/generated/findloc1_i2.c      |  116 +--
 libgfortran/generated/findloc1_i4.c      |  116 +--
 libgfortran/generated/findloc1_i8.c      |  116 +--
 libgfortran/generated/findloc1_r10.c     |  116 +--
 libgfortran/generated/findloc1_r16.c     |  116 +--
 libgfortran/generated/findloc1_r17.c     |  116 +--
 libgfortran/generated/findloc1_r4.c      |  116 +--
 libgfortran/generated/findloc1_r8.c      |  116 +--
 libgfortran/generated/findloc1_s1.c      |  116 +--
 libgfortran/generated/findloc1_s4.c      |  116 +--
 libgfortran/generated/findloc2_s1.c      |   30 +-
 libgfortran/generated/findloc2_s4.c      |   30 +-
 libgfortran/generated/iall_i1.c          |  118 +--
 libgfortran/generated/iall_i16.c         |  118 +--
 libgfortran/generated/iall_i2.c          |  118 +--
 libgfortran/generated/iall_i4.c          |  118 +--
 libgfortran/generated/iall_i8.c          |  118 +--
 libgfortran/generated/iany_i1.c          |  118 +--
 libgfortran/generated/iany_i16.c         |  118 +--
 libgfortran/generated/iany_i2.c          |  118 +--
 libgfortran/generated/iany_i4.c          |  118 +--
 libgfortran/generated/iany_i8.c          |  118 +--
 libgfortran/generated/in_pack_c10.c      |   20 +-
 libgfortran/generated/in_pack_c16.c      |   20 +-
 libgfortran/generated/in_pack_c17.c      |   20 +-
 libgfortran/generated/in_pack_c4.c       |   20 +-
 libgfortran/generated/in_pack_c8.c       |   20 +-
 libgfortran/generated/in_pack_i1.c       |   20 +-
 libgfortran/generated/in_pack_i16.c      |   20 +-
 libgfortran/generated/in_pack_i2.c       |   20 +-
 libgfortran/generated/in_pack_i4.c       |   20 +-
 libgfortran/generated/in_pack_i8.c       |   20 +-
 libgfortran/generated/in_pack_r10.c      |   20 +-
 libgfortran/generated/in_pack_r16.c      |   20 +-
 libgfortran/generated/in_pack_r17.c      |   20 +-
 libgfortran/generated/in_pack_r4.c       |   20 +-
 libgfortran/generated/in_pack_r8.c       |   20 +-
 libgfortran/generated/in_unpack_c10.c    |   20 +-
 libgfortran/generated/in_unpack_c16.c    |   20 +-
 libgfortran/generated/in_unpack_c17.c    |   20 +-
 libgfortran/generated/in_unpack_c4.c     |   20 +-
 libgfortran/generated/in_unpack_c8.c     |   20 +-
 libgfortran/generated/in_unpack_i1.c     |   20 +-
 libgfortran/generated/in_unpack_i16.c    |   20 +-
 libgfortran/generated/in_unpack_i2.c     |   20 +-
 libgfortran/generated/in_unpack_i4.c     |   20 +-
 libgfortran/generated/in_unpack_i8.c     |   20 +-
 libgfortran/generated/in_unpack_r10.c    |   20 +-
 libgfortran/generated/in_unpack_r16.c    |   20 +-
 libgfortran/generated/in_unpack_r17.c    |   20 +-
 libgfortran/generated/in_unpack_r4.c     |   20 +-
 libgfortran/generated/in_unpack_r8.c     |   20 +-
 libgfortran/generated/iparity_i1.c       |  118 +--
 libgfortran/generated/iparity_i16.c      |  118 +--
 libgfortran/generated/iparity_i2.c       |  118 +--
 libgfortran/generated/iparity_i4.c       |  118 +--
 libgfortran/generated/iparity_i8.c       |  118 +--
 libgfortran/generated/matmul_c10.c       | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_c16.c       | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_c17.c       | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_c4.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_c8.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_i1.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_i16.c       | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_i2.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_i4.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_i8.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_l16.c       |   46 +-
 libgfortran/generated/matmul_l4.c        |   46 +-
 libgfortran/generated/matmul_l8.c        |   46 +-
 libgfortran/generated/matmul_r10.c       | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_r16.c       | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_r17.c       | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_r4.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmul_r8.c        | 1555 ++++++++++++++++--------------
 libgfortran/generated/matmulavx128_c10.c |  622 ++++++------
 libgfortran/generated/matmulavx128_c16.c |  622 ++++++------
 libgfortran/generated/matmulavx128_c17.c |  622 ++++++------
 libgfortran/generated/matmulavx128_c4.c  |  622 ++++++------
 libgfortran/generated/matmulavx128_c8.c  |  622 ++++++------
 libgfortran/generated/matmulavx128_i1.c  |  622 ++++++------
 libgfortran/generated/matmulavx128_i16.c |  622 ++++++------
 libgfortran/generated/matmulavx128_i2.c  |  622 ++++++------
 libgfortran/generated/matmulavx128_i4.c  |  622 ++++++------
 libgfortran/generated/matmulavx128_i8.c  |  622 ++++++------
 libgfortran/generated/matmulavx128_r10.c |  622 ++++++------
 libgfortran/generated/matmulavx128_r16.c |  622 ++++++------
 libgfortran/generated/matmulavx128_r17.c |  622 ++++++------
 libgfortran/generated/matmulavx128_r4.c  |  622 ++++++------
 libgfortran/generated/matmulavx128_r8.c  |  622 ++++++------
 libgfortran/generated/maxloc0_16_i1.c    |   88 +-
 libgfortran/generated/maxloc0_16_i16.c   |   88 +-
 libgfortran/generated/maxloc0_16_i2.c    |   88 +-
 libgfortran/generated/maxloc0_16_i4.c    |   88 +-
 libgfortran/generated/maxloc0_16_i8.c    |   88 +-
 libgfortran/generated/maxloc0_16_m1.c    |   88 +-
 libgfortran/generated/maxloc0_16_m16.c   |   88 +-
 libgfortran/generated/maxloc0_16_m2.c    |   88 +-
 libgfortran/generated/maxloc0_16_m4.c    |   88 +-
 libgfortran/generated/maxloc0_16_m8.c    |   88 +-
 libgfortran/generated/maxloc0_16_r10.c   |   88 +-
 libgfortran/generated/maxloc0_16_r16.c   |   88 +-
 libgfortran/generated/maxloc0_16_r17.c   |   88 +-
 libgfortran/generated/maxloc0_16_r4.c    |   88 +-
 libgfortran/generated/maxloc0_16_r8.c    |   88 +-
 libgfortran/generated/maxloc0_16_s1.c    |   78 +-
 libgfortran/generated/maxloc0_16_s4.c    |   78 +-
 libgfortran/generated/maxloc0_4_i1.c     |   88 +-
 libgfortran/generated/maxloc0_4_i16.c    |   88 +-
 libgfortran/generated/maxloc0_4_i2.c     |   88 +-
 libgfortran/generated/maxloc0_4_i4.c     |   88 +-
 libgfortran/generated/maxloc0_4_i8.c     |   88 +-
 libgfortran/generated/maxloc0_4_m1.c     |   88 +-
 libgfortran/generated/maxloc0_4_m16.c    |   88 +-
 libgfortran/generated/maxloc0_4_m2.c     |   88 +-
 libgfortran/generated/maxloc0_4_m4.c     |   88 +-
 libgfortran/generated/maxloc0_4_m8.c     |   88 +-
 libgfortran/generated/maxloc0_4_r10.c    |   88 +-
 libgfortran/generated/maxloc0_4_r16.c    |   88 +-
 libgfortran/generated/maxloc0_4_r17.c    |   88 +-
 libgfortran/generated/maxloc0_4_r4.c     |   88 +-
 libgfortran/generated/maxloc0_4_r8.c     |   88 +-
 libgfortran/generated/maxloc0_4_s1.c     |   78 +-
 libgfortran/generated/maxloc0_4_s4.c     |   78 +-
 libgfortran/generated/maxloc0_8_i1.c     |   88 +-
 libgfortran/generated/maxloc0_8_i16.c    |   88 +-
 libgfortran/generated/maxloc0_8_i2.c     |   88 +-
 libgfortran/generated/maxloc0_8_i4.c     |   88 +-
 libgfortran/generated/maxloc0_8_i8.c     |   88 +-
 libgfortran/generated/maxloc0_8_m1.c     |   88 +-
 libgfortran/generated/maxloc0_8_m16.c    |   88 +-
 libgfortran/generated/maxloc0_8_m2.c     |   88 +-
 libgfortran/generated/maxloc0_8_m4.c     |   88 +-
 libgfortran/generated/maxloc0_8_m8.c     |   88 +-
 libgfortran/generated/maxloc0_8_r10.c    |   88 +-
 libgfortran/generated/maxloc0_8_r16.c    |   88 +-
 libgfortran/generated/maxloc0_8_r17.c    |   88 +-
 libgfortran/generated/maxloc0_8_r4.c     |   88 +-
 libgfortran/generated/maxloc0_8_r8.c     |   88 +-
 libgfortran/generated/maxloc0_8_s1.c     |   78 +-
 libgfortran/generated/maxloc0_8_s4.c     |   78 +-
 libgfortran/generated/maxloc1_16_i1.c    |  132 +--
 libgfortran/generated/maxloc1_16_i16.c   |  132 +--
 libgfortran/generated/maxloc1_16_i2.c    |  132 +--
 libgfortran/generated/maxloc1_16_i4.c    |  132 +--
 libgfortran/generated/maxloc1_16_i8.c    |  132 +--
 libgfortran/generated/maxloc1_16_m1.c    |  132 +--
 libgfortran/generated/maxloc1_16_m16.c   |  132 +--
 libgfortran/generated/maxloc1_16_m2.c    |  132 +--
 libgfortran/generated/maxloc1_16_m4.c    |  132 +--
 libgfortran/generated/maxloc1_16_m8.c    |  132 +--
 libgfortran/generated/maxloc1_16_r10.c   |  132 +--
 libgfortran/generated/maxloc1_16_r16.c   |  132 +--
 libgfortran/generated/maxloc1_16_r17.c   |  132 +--
 libgfortran/generated/maxloc1_16_r4.c    |  132 +--
 libgfortran/generated/maxloc1_16_r8.c    |  132 +--
 libgfortran/generated/maxloc1_16_s1.c    |   99 +-
 libgfortran/generated/maxloc1_16_s4.c    |   99 +-
 libgfortran/generated/maxloc1_4_i1.c     |  132 +--
 libgfortran/generated/maxloc1_4_i16.c    |  132 +--
 libgfortran/generated/maxloc1_4_i2.c     |  132 +--
 libgfortran/generated/maxloc1_4_i4.c     |  132 +--
 libgfortran/generated/maxloc1_4_i8.c     |  132 +--
 libgfortran/generated/maxloc1_4_m1.c     |  132 +--
 libgfortran/generated/maxloc1_4_m16.c    |  132 +--
 libgfortran/generated/maxloc1_4_m2.c     |  132 +--
 libgfortran/generated/maxloc1_4_m4.c     |  132 +--
 libgfortran/generated/maxloc1_4_m8.c     |  132 +--
 libgfortran/generated/maxloc1_4_r10.c    |  132 +--
 libgfortran/generated/maxloc1_4_r16.c    |  132 +--
 libgfortran/generated/maxloc1_4_r17.c    |  132 +--
 libgfortran/generated/maxloc1_4_r4.c     |  132 +--
 libgfortran/generated/maxloc1_4_r8.c     |  132 +--
 libgfortran/generated/maxloc1_4_s1.c     |   99 +-
 libgfortran/generated/maxloc1_4_s4.c     |   99 +-
 libgfortran/generated/maxloc1_8_i1.c     |  132 +--
 libgfortran/generated/maxloc1_8_i16.c    |  132 +--
 libgfortran/generated/maxloc1_8_i2.c     |  132 +--
 libgfortran/generated/maxloc1_8_i4.c     |  132 +--
 libgfortran/generated/maxloc1_8_i8.c     |  132 +--
 libgfortran/generated/maxloc1_8_m1.c     |  132 +--
 libgfortran/generated/maxloc1_8_m16.c    |  132 +--
 libgfortran/generated/maxloc1_8_m2.c     |  132 +--
 libgfortran/generated/maxloc1_8_m4.c     |  132 +--
 libgfortran/generated/maxloc1_8_m8.c     |  132 +--
 libgfortran/generated/maxloc1_8_r10.c    |  132 +--
 libgfortran/generated/maxloc1_8_r16.c    |  132 +--
 libgfortran/generated/maxloc1_8_r17.c    |  132 +--
 libgfortran/generated/maxloc1_8_r4.c     |  132 +--
 libgfortran/generated/maxloc1_8_r8.c     |  132 +--
 libgfortran/generated/maxloc1_8_s1.c     |   99 +-
 libgfortran/generated/maxloc1_8_s4.c     |   99 +-
 libgfortran/generated/maxloc2_16_s1.c    |   22 +-
 libgfortran/generated/maxloc2_16_s4.c    |   22 +-
 libgfortran/generated/maxloc2_4_s1.c     |   22 +-
 libgfortran/generated/maxloc2_4_s4.c     |   22 +-
 libgfortran/generated/maxloc2_8_s1.c     |   22 +-
 libgfortran/generated/maxloc2_8_s4.c     |   22 +-
 libgfortran/generated/maxval0_s1.c       |   30 +-
 libgfortran/generated/maxval0_s4.c       |   30 +-
 libgfortran/generated/maxval1_s1.c       |  120 ++-
 libgfortran/generated/maxval1_s4.c       |  120 ++-
 libgfortran/generated/maxval_i1.c        |  126 +--
 libgfortran/generated/maxval_i16.c       |  126 +--
 libgfortran/generated/maxval_i2.c        |  126 +--
 libgfortran/generated/maxval_i4.c        |  126 +--
 libgfortran/generated/maxval_i8.c        |  126 +--
 libgfortran/generated/maxval_m1.c        |  126 +--
 libgfortran/generated/maxval_m16.c       |  126 +--
 libgfortran/generated/maxval_m2.c        |  126 +--
 libgfortran/generated/maxval_m4.c        |  126 +--
 libgfortran/generated/maxval_m8.c        |  126 +--
 libgfortran/generated/maxval_r10.c       |  126 +--
 libgfortran/generated/maxval_r16.c       |  126 +--
 libgfortran/generated/maxval_r17.c       |  126 +--
 libgfortran/generated/maxval_r4.c        |  126 +--
 libgfortran/generated/maxval_r8.c        |  126 +--
 libgfortran/generated/minloc0_16_i1.c    |   88 +-
 libgfortran/generated/minloc0_16_i16.c   |   88 +-
 libgfortran/generated/minloc0_16_i2.c    |   88 +-
 libgfortran/generated/minloc0_16_i4.c    |   88 +-
 libgfortran/generated/minloc0_16_i8.c    |   88 +-
 libgfortran/generated/minloc0_16_m1.c    |   88 +-
 libgfortran/generated/minloc0_16_m16.c   |   88 +-
 libgfortran/generated/minloc0_16_m2.c    |   88 +-
 libgfortran/generated/minloc0_16_m4.c    |   88 +-
 libgfortran/generated/minloc0_16_m8.c    |   88 +-
 libgfortran/generated/minloc0_16_r10.c   |   88 +-
 libgfortran/generated/minloc0_16_r16.c   |   88 +-
 libgfortran/generated/minloc0_16_r17.c   |   88 +-
 libgfortran/generated/minloc0_16_r4.c    |   88 +-
 libgfortran/generated/minloc0_16_r8.c    |   88 +-
 libgfortran/generated/minloc0_16_s1.c    |   78 +-
 libgfortran/generated/minloc0_16_s4.c    |   78 +-
 libgfortran/generated/minloc0_4_i1.c     |   88 +-
 libgfortran/generated/minloc0_4_i16.c    |   88 +-
 libgfortran/generated/minloc0_4_i2.c     |   88 +-
 libgfortran/generated/minloc0_4_i4.c     |   88 +-
 libgfortran/generated/minloc0_4_i8.c     |   88 +-
 libgfortran/generated/minloc0_4_m1.c     |   88 +-
 libgfortran/generated/minloc0_4_m16.c    |   88 +-
 libgfortran/generated/minloc0_4_m2.c     |   88 +-
 libgfortran/generated/minloc0_4_m4.c     |   88 +-
 libgfortran/generated/minloc0_4_m8.c     |   88 +-
 libgfortran/generated/minloc0_4_r10.c    |   88 +-
 libgfortran/generated/minloc0_4_r16.c    |   88 +-
 libgfortran/generated/minloc0_4_r17.c    |   88 +-
 libgfortran/generated/minloc0_4_r4.c     |   88 +-
 libgfortran/generated/minloc0_4_r8.c     |   88 +-
 libgfortran/generated/minloc0_4_s1.c     |   78 +-
 libgfortran/generated/minloc0_4_s4.c     |   78 +-
 libgfortran/generated/minloc0_8_i1.c     |   88 +-
 libgfortran/generated/minloc0_8_i16.c    |   88 +-
 libgfortran/generated/minloc0_8_i2.c     |   88 +-
 libgfortran/generated/minloc0_8_i4.c     |   88 +-
 libgfortran/generated/minloc0_8_i8.c     |   88 +-
 libgfortran/generated/minloc0_8_m1.c     |   88 +-
 libgfortran/generated/minloc0_8_m16.c    |   88 +-
 libgfortran/generated/minloc0_8_m2.c     |   88 +-
 libgfortran/generated/minloc0_8_m4.c     |   88 +-
 libgfortran/generated/minloc0_8_m8.c     |   88 +-
 libgfortran/generated/minloc0_8_r10.c    |   88 +-
 libgfortran/generated/minloc0_8_r16.c    |   88 +-
 libgfortran/generated/minloc0_8_r17.c    |   88 +-
 libgfortran/generated/minloc0_8_r4.c     |   88 +-
 libgfortran/generated/minloc0_8_r8.c     |   88 +-
 libgfortran/generated/minloc0_8_s1.c     |   78 +-
 libgfortran/generated/minloc0_8_s4.c     |   78 +-
 libgfortran/generated/minloc1_16_i1.c    |  136 +--
 libgfortran/generated/minloc1_16_i16.c   |  136 +--
 libgfortran/generated/minloc1_16_i2.c    |  136 +--
 libgfortran/generated/minloc1_16_i4.c    |  136 +--
 libgfortran/generated/minloc1_16_i8.c    |  136 +--
 libgfortran/generated/minloc1_16_m1.c    |  136 +--
 libgfortran/generated/minloc1_16_m16.c   |  136 +--
 libgfortran/generated/minloc1_16_m2.c    |  136 +--
 libgfortran/generated/minloc1_16_m4.c    |  136 +--
 libgfortran/generated/minloc1_16_m8.c    |  136 +--
 libgfortran/generated/minloc1_16_r10.c   |  136 +--
 libgfortran/generated/minloc1_16_r16.c   |  136 +--
 libgfortran/generated/minloc1_16_r17.c   |  136 +--
 libgfortran/generated/minloc1_16_r4.c    |  136 +--
 libgfortran/generated/minloc1_16_r8.c    |  136 +--
 libgfortran/generated/minloc1_16_s1.c    |   99 +-
 libgfortran/generated/minloc1_16_s4.c    |   99 +-
 libgfortran/generated/minloc1_4_i1.c     |  136 +--
 libgfortran/generated/minloc1_4_i16.c    |  136 +--
 libgfortran/generated/minloc1_4_i2.c     |  136 +--
 libgfortran/generated/minloc1_4_i4.c     |  136 +--
 libgfortran/generated/minloc1_4_i8.c     |  136 +--
 libgfortran/generated/minloc1_4_m1.c     |  136 +--
 libgfortran/generated/minloc1_4_m16.c    |  136 +--
 libgfortran/generated/minloc1_4_m2.c     |  136 +--
 libgfortran/generated/minloc1_4_m4.c     |  136 +--
 libgfortran/generated/minloc1_4_m8.c     |  136 +--
 libgfortran/generated/minloc1_4_r10.c    |  136 +--
 libgfortran/generated/minloc1_4_r16.c    |  136 +--
 libgfortran/generated/minloc1_4_r17.c    |  136 +--
 libgfortran/generated/minloc1_4_r4.c     |  136 +--
 libgfortran/generated/minloc1_4_r8.c     |  136 +--
 libgfortran/generated/minloc1_4_s1.c     |   99 +-
 libgfortran/generated/minloc1_4_s4.c     |   99 +-
 libgfortran/generated/minloc1_8_i1.c     |  136 +--
 libgfortran/generated/minloc1_8_i16.c    |  136 +--
 libgfortran/generated/minloc1_8_i2.c     |  136 +--
 libgfortran/generated/minloc1_8_i4.c     |  136 +--
 libgfortran/generated/minloc1_8_i8.c     |  136 +--
 libgfortran/generated/minloc1_8_m1.c     |  136 +--
 libgfortran/generated/minloc1_8_m16.c    |  136 +--
 libgfortran/generated/minloc1_8_m2.c     |  136 +--
 libgfortran/generated/minloc1_8_m4.c     |  136 +--
 libgfortran/generated/minloc1_8_m8.c     |  136 +--
 libgfortran/generated/minloc1_8_r10.c    |  136 +--
 libgfortran/generated/minloc1_8_r16.c    |  136 +--
 libgfortran/generated/minloc1_8_r17.c    |  136 +--
 libgfortran/generated/minloc1_8_r4.c     |  136 +--
 libgfortran/generated/minloc1_8_r8.c     |  136 +--
 libgfortran/generated/minloc1_8_s1.c     |   99 +-
 libgfortran/generated/minloc1_8_s4.c     |   99 +-
 libgfortran/generated/minloc2_16_s1.c    |   22 +-
 libgfortran/generated/minloc2_16_s4.c    |   22 +-
 libgfortran/generated/minloc2_4_s1.c     |   22 +-
 libgfortran/generated/minloc2_4_s4.c     |   22 +-
 libgfortran/generated/minloc2_8_s1.c     |   22 +-
 libgfortran/generated/minloc2_8_s4.c     |   22 +-
 libgfortran/generated/minval0_s1.c       |   30 +-
 libgfortran/generated/minval0_s4.c       |   30 +-
 libgfortran/generated/minval1_s1.c       |  120 ++-
 libgfortran/generated/minval1_s4.c       |  120 ++-
 libgfortran/generated/minval_i1.c        |  126 +--
 libgfortran/generated/minval_i16.c       |  126 +--
 libgfortran/generated/minval_i2.c        |  126 +--
 libgfortran/generated/minval_i4.c        |  126 +--
 libgfortran/generated/minval_i8.c        |  126 +--
 libgfortran/generated/minval_m1.c        |  126 +--
 libgfortran/generated/minval_m16.c       |  126 +--
 libgfortran/generated/minval_m2.c        |  126 +--
 libgfortran/generated/minval_m4.c        |  126 +--
 libgfortran/generated/minval_m8.c        |  126 +--
 libgfortran/generated/minval_r10.c       |  126 +--
 libgfortran/generated/minval_r16.c       |  126 +--
 libgfortran/generated/minval_r17.c       |  126 +--
 libgfortran/generated/minval_r4.c        |  126 +--
 libgfortran/generated/minval_r8.c        |  126 +--
 libgfortran/generated/norm2_r10.c        |   40 +-
 libgfortran/generated/norm2_r16.c        |   40 +-
 libgfortran/generated/norm2_r17.c        |   40 +-
 libgfortran/generated/norm2_r4.c         |   40 +-
 libgfortran/generated/norm2_r8.c         |   40 +-
 libgfortran/generated/pack_c10.c         |   60 +-
 libgfortran/generated/pack_c16.c         |   60 +-
 libgfortran/generated/pack_c17.c         |   60 +-
 libgfortran/generated/pack_c4.c          |   60 +-
 libgfortran/generated/pack_c8.c          |   60 +-
 libgfortran/generated/pack_i1.c          |   60 +-
 libgfortran/generated/pack_i16.c         |   60 +-
 libgfortran/generated/pack_i2.c          |   60 +-
 libgfortran/generated/pack_i4.c          |   60 +-
 libgfortran/generated/pack_i8.c          |   60 +-
 libgfortran/generated/pack_r10.c         |   60 +-
 libgfortran/generated/pack_r16.c         |   60 +-
 libgfortran/generated/pack_r17.c         |   60 +-
 libgfortran/generated/pack_r4.c          |   60 +-
 libgfortran/generated/pack_r8.c          |   60 +-
 libgfortran/generated/parity_l1.c        |   40 +-
 libgfortran/generated/parity_l16.c       |   40 +-
 libgfortran/generated/parity_l2.c        |   40 +-
 libgfortran/generated/parity_l4.c        |   40 +-
 libgfortran/generated/parity_l8.c        |   40 +-
 libgfortran/generated/product_c10.c      |  118 +--
 libgfortran/generated/product_c16.c      |  118 +--
 libgfortran/generated/product_c17.c      |  118 +--
 libgfortran/generated/product_c4.c       |  118 +--
 libgfortran/generated/product_c8.c       |  118 +--
 libgfortran/generated/product_i1.c       |  118 +--
 libgfortran/generated/product_i16.c      |  118 +--
 libgfortran/generated/product_i2.c       |  118 +--
 libgfortran/generated/product_i4.c       |  118 +--
 libgfortran/generated/product_i8.c       |  118 +--
 libgfortran/generated/product_r10.c      |  118 +--
 libgfortran/generated/product_r16.c      |  118 +--
 libgfortran/generated/product_r17.c      |  118 +--
 libgfortran/generated/product_r4.c       |  118 +--
 libgfortran/generated/product_r8.c       |  118 +--
 libgfortran/generated/reshape_c10.c      |   67 +-
 libgfortran/generated/reshape_c16.c      |   67 +-
 libgfortran/generated/reshape_c17.c      |   67 +-
 libgfortran/generated/reshape_c4.c       |   67 +-
 libgfortran/generated/reshape_c8.c       |   67 +-
 libgfortran/generated/reshape_i16.c      |   67 +-
 libgfortran/generated/reshape_i4.c       |   67 +-
 libgfortran/generated/reshape_i8.c       |   67 +-
 libgfortran/generated/reshape_r10.c      |   67 +-
 libgfortran/generated/reshape_r16.c      |   67 +-
 libgfortran/generated/reshape_r17.c      |   67 +-
 libgfortran/generated/reshape_r4.c       |   67 +-
 libgfortran/generated/reshape_r8.c       |   67 +-
 libgfortran/generated/shape_i1.c         |    7 +-
 libgfortran/generated/shape_i16.c        |    7 +-
 libgfortran/generated/shape_i2.c         |    7 +-
 libgfortran/generated/shape_i4.c         |    7 +-
 libgfortran/generated/shape_i8.c         |    7 +-
 libgfortran/generated/spread_c10.c       |   69 +-
 libgfortran/generated/spread_c16.c       |   69 +-
 libgfortran/generated/spread_c17.c       |   69 +-
 libgfortran/generated/spread_c4.c        |   69 +-
 libgfortran/generated/spread_c8.c        |   69 +-
 libgfortran/generated/spread_i1.c        |   69 +-
 libgfortran/generated/spread_i16.c       |   69 +-
 libgfortran/generated/spread_i2.c        |   69 +-
 libgfortran/generated/spread_i4.c        |   69 +-
 libgfortran/generated/spread_i8.c        |   69 +-
 libgfortran/generated/spread_r10.c       |   69 +-
 libgfortran/generated/spread_r16.c       |   69 +-
 libgfortran/generated/spread_r17.c       |   69 +-
 libgfortran/generated/spread_r4.c        |   69 +-
 libgfortran/generated/spread_r8.c        |   69 +-
 libgfortran/generated/sum_c10.c          |  118 +--
 libgfortran/generated/sum_c16.c          |  118 +--
 libgfortran/generated/sum_c17.c          |  118 +--
 libgfortran/generated/sum_c4.c           |  118 +--
 libgfortran/generated/sum_c8.c           |  118 +--
 libgfortran/generated/sum_i1.c           |  118 +--
 libgfortran/generated/sum_i16.c          |  118 +--
 libgfortran/generated/sum_i2.c           |  118 +--
 libgfortran/generated/sum_i4.c           |  118 +--
 libgfortran/generated/sum_i8.c           |  118 +--
 libgfortran/generated/sum_r10.c          |  118 +--
 libgfortran/generated/sum_r16.c          |  118 +--
 libgfortran/generated/sum_r17.c          |  118 +--
 libgfortran/generated/sum_r4.c           |  118 +--
 libgfortran/generated/sum_r8.c           |  118 +--
 libgfortran/generated/unpack_c10.c       |  124 ++-
 libgfortran/generated/unpack_c16.c       |  124 ++-
 libgfortran/generated/unpack_c17.c       |  124 ++-
 libgfortran/generated/unpack_c4.c        |  124 ++-
 libgfortran/generated/unpack_c8.c        |  124 ++-
 libgfortran/generated/unpack_i1.c        |  124 ++-
 libgfortran/generated/unpack_i16.c       |  124 ++-
 libgfortran/generated/unpack_i2.c        |  124 ++-
 libgfortran/generated/unpack_i4.c        |  124 ++-
 libgfortran/generated/unpack_i8.c        |  124 ++-
 libgfortran/generated/unpack_r10.c       |  124 ++-
 libgfortran/generated/unpack_r16.c       |  124 ++-
 libgfortran/generated/unpack_r17.c       |  124 ++-
 libgfortran/generated/unpack_r4.c        |  124 ++-
 libgfortran/generated/unpack_r8.c        |  124 ++-
 560 files changed, 41705 insertions(+), 38494 deletions(-)

diff --git a/libgfortran/generated/all_l1.c b/libgfortran/generated/all_l1.c
index 848f86a604f8..adfc943c4a8f 100644
--- a/libgfortran/generated/all_l1.c
+++ b/libgfortran/generated/all_l1.c
@@ -40,8 +40,8 @@ all_l1 (gfc_array_l1 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_1 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ all_l1 (gfc_array_l1 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ all_l1 (gfc_array_l1 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ all_l1 (gfc_array_l1 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_1);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ all_l1 (gfc_array_l1 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ all_l1 (gfc_array_l1 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_1*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ all_l1 (gfc_array_l1 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_1*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ all_l1 (gfc_array_l1 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_1*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/all_l16.c b/libgfortran/generated/all_l16.c
index cd3c019a0afc..b69d86293c02 100644
--- a/libgfortran/generated/all_l16.c
+++ b/libgfortran/generated/all_l16.c
@@ -40,8 +40,8 @@ all_l16 (gfc_array_l16 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_16 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ all_l16 (gfc_array_l16 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ all_l16 (gfc_array_l16 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ all_l16 (gfc_array_l16 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_16);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_16));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ all_l16 (gfc_array_l16 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ all_l16 (gfc_array_l16 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_16*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ all_l16 (gfc_array_l16 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_16*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ all_l16 (gfc_array_l16 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_16*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/all_l2.c b/libgfortran/generated/all_l2.c
index 98135759ce42..b833dfc3fc76 100644
--- a/libgfortran/generated/all_l2.c
+++ b/libgfortran/generated/all_l2.c
@@ -40,8 +40,8 @@ all_l2 (gfc_array_l2 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_2 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ all_l2 (gfc_array_l2 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ all_l2 (gfc_array_l2 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ all_l2 (gfc_array_l2 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_2);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_2));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ all_l2 (gfc_array_l2 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ all_l2 (gfc_array_l2 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_2*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ all_l2 (gfc_array_l2 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_2*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ all_l2 (gfc_array_l2 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_2*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/all_l4.c b/libgfortran/generated/all_l4.c
index 7ca764734291..1957544e46b9 100644
--- a/libgfortran/generated/all_l4.c
+++ b/libgfortran/generated/all_l4.c
@@ -40,8 +40,8 @@ all_l4 (gfc_array_l4 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_4 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ all_l4 (gfc_array_l4 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ all_l4 (gfc_array_l4 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ all_l4 (gfc_array_l4 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_4);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ all_l4 (gfc_array_l4 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ all_l4 (gfc_array_l4 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_4*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ all_l4 (gfc_array_l4 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_4*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ all_l4 (gfc_array_l4 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_4*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/all_l8.c b/libgfortran/generated/all_l8.c
index 3171c72ea2e3..00f6ad2d6c0b 100644
--- a/libgfortran/generated/all_l8.c
+++ b/libgfortran/generated/all_l8.c
@@ -40,8 +40,8 @@ all_l8 (gfc_array_l8 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_8 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ all_l8 (gfc_array_l8 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ all_l8 (gfc_array_l8 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ all_l8 (gfc_array_l8 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_8);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_8));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ all_l8 (gfc_array_l8 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ all_l8 (gfc_array_l8 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_8*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ all_l8 (gfc_array_l8 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_8*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ all_l8 (gfc_array_l8 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_8*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/any_l1.c b/libgfortran/generated/any_l1.c
index 6099621e13e4..0c8a86e974f6 100644
--- a/libgfortran/generated/any_l1.c
+++ b/libgfortran/generated/any_l1.c
@@ -40,8 +40,8 @@ any_l1 (gfc_array_l1 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_1 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ any_l1 (gfc_array_l1 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ any_l1 (gfc_array_l1 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ any_l1 (gfc_array_l1 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_1);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ any_l1 (gfc_array_l1 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ any_l1 (gfc_array_l1 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_1*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ any_l1 (gfc_array_l1 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_1*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ any_l1 (gfc_array_l1 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_1*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/any_l16.c b/libgfortran/generated/any_l16.c
index 2c38cdbc0721..2fdc103f7e23 100644
--- a/libgfortran/generated/any_l16.c
+++ b/libgfortran/generated/any_l16.c
@@ -40,8 +40,8 @@ any_l16 (gfc_array_l16 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_16 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ any_l16 (gfc_array_l16 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ any_l16 (gfc_array_l16 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ any_l16 (gfc_array_l16 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_16);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_16));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ any_l16 (gfc_array_l16 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ any_l16 (gfc_array_l16 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_16*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ any_l16 (gfc_array_l16 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_16*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ any_l16 (gfc_array_l16 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_16*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/any_l2.c b/libgfortran/generated/any_l2.c
index 0d52c7c6fda1..b2e0b06eb088 100644
--- a/libgfortran/generated/any_l2.c
+++ b/libgfortran/generated/any_l2.c
@@ -40,8 +40,8 @@ any_l2 (gfc_array_l2 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_2 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ any_l2 (gfc_array_l2 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ any_l2 (gfc_array_l2 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ any_l2 (gfc_array_l2 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_2);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_2));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ any_l2 (gfc_array_l2 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ any_l2 (gfc_array_l2 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_2*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ any_l2 (gfc_array_l2 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_2*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ any_l2 (gfc_array_l2 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_2*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/any_l4.c b/libgfortran/generated/any_l4.c
index b865789124b4..e5141e0b2d8d 100644
--- a/libgfortran/generated/any_l4.c
+++ b/libgfortran/generated/any_l4.c
@@ -40,8 +40,8 @@ any_l4 (gfc_array_l4 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_4 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ any_l4 (gfc_array_l4 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ any_l4 (gfc_array_l4 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ any_l4 (gfc_array_l4 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_4);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ any_l4 (gfc_array_l4 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ any_l4 (gfc_array_l4 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_4*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ any_l4 (gfc_array_l4 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_4*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ any_l4 (gfc_array_l4 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_4*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/any_l8.c b/libgfortran/generated/any_l8.c
index d437a1b9e59f..ae70e6f2702b 100644
--- a/libgfortran/generated/any_l8.c
+++ b/libgfortran/generated/any_l8.c
@@ -40,8 +40,8 @@ any_l8 (gfc_array_l8 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_LOGICAL_8 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ any_l8 (gfc_array_l8 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ any_l8 (gfc_array_l8 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ any_l8 (gfc_array_l8 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_LOGICAL_8);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_LOGICAL_8));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ any_l8 (gfc_array_l8 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -181,8 +180,8 @@ any_l8 (gfc_array_l8 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_LOGICAL_8*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -191,8 +190,8 @@ any_l8 (gfc_array_l8 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_LOGICAL_8*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -203,8 +202,8 @@ any_l8 (gfc_array_l8 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_LOGICAL_8*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/bessel_r10.c b/libgfortran/generated/bessel_r10.c
index f95528090cb6..663b84a08123 100644
--- a/libgfortran/generated/bessel_r10.c
+++ b/libgfortran/generated/bessel_r10.c
@@ -43,16 +43,16 @@ void
 bessel_jn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2, GFC_REAL_10 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_10 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_10));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_10));
       ret->offset = 0;
     }
@@ -66,24 +66,24 @@ bessel_jn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2, GFC_REAL_10 x
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       ret->base_addr[0] = 1;
       for (i = 1; i <= n2-n1; i++)
-        ret->base_addr[i*stride] = 0;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i) = 0;
       return;
     }
 
   last1 = MATHFUNC(jn) (n2, x);
-  ret->base_addr[(n2-n1)*stride] = last1;
+  GFC_ARRAY_ELEM (GFC_REAL_10, ret->base_addr, (n2-n1)*spacing) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(jn) (n2 - 1, x);
-  ret->base_addr[(n2-n1-1)*stride] = last2;
+  GFC_ARRAY_ELEM (GFC_REAL_10, ret->base_addr, (n2-n1-1)*spacing) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -92,9 +92,9 @@ bessel_jn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2, GFC_REAL_10 x
 
   for (i = n2-n1-2; i >= 0; i--)
     {
-      ret->base_addr[i*stride] = x2rev * (i+1+n1) * last2 - last1;
+      GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i) = x2rev * (i+1+n1) * last2 - last1;
       last1 = last2;
-      last2 = ret->base_addr[i*stride];
+      last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i);
     }
 }
 
@@ -110,16 +110,16 @@ bessel_yn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2,
 			 GFC_REAL_10 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_10 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_10));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_10));
       ret->offset = 0;
     }
@@ -133,27 +133,27 @@ bessel_yn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2,
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       for (i = 0; i <= n2-n1; i++)
 #if defined(GFC_REAL_10_INFINITY)
-        ret->base_addr[i*stride] = -GFC_REAL_10_INFINITY;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i) = -GFC_REAL_10_INFINITY;
 #else
-        ret->base_addr[i*stride] = -GFC_REAL_10_HUGE;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i) = -GFC_REAL_10_HUGE;
 #endif
       return;
     }
 
   last1 = MATHFUNC(yn) (n1, x);
-  ret->base_addr[0] = last1;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, 0) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(yn) (n1 + 1, x);
-  ret->base_addr[1*stride] = last2;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, 1) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -165,14 +165,14 @@ bessel_yn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2,
 #if defined(GFC_REAL_10_INFINITY)
       if (unlikely (last2 == -GFC_REAL_10_INFINITY))
 	{
-	  ret->base_addr[i*stride] = -GFC_REAL_10_INFINITY;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i) = -GFC_REAL_10_INFINITY;
 	}
       else
 #endif
 	{
-	  ret->base_addr[i*stride] = x2rev * (i-1+n1) * last2 - last1;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i) = x2rev * (i-1+n1) * last2 - last1;
 	  last1 = last2;
-	  last2 = ret->base_addr[i*stride];
+	  last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_10, ret, i);
 	}
     }
 }
diff --git a/libgfortran/generated/bessel_r16.c b/libgfortran/generated/bessel_r16.c
index e6c1402d0e58..79c08309596d 100644
--- a/libgfortran/generated/bessel_r16.c
+++ b/libgfortran/generated/bessel_r16.c
@@ -51,16 +51,16 @@ void
 bessel_jn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2, GFC_REAL_16 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_16 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_16));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_16));
       ret->offset = 0;
     }
@@ -74,24 +74,24 @@ bessel_jn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2, GFC_REAL_16 x
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       ret->base_addr[0] = 1;
       for (i = 1; i <= n2-n1; i++)
-        ret->base_addr[i*stride] = 0;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i) = 0;
       return;
     }
 
   last1 = MATHFUNC(jn) (n2, x);
-  ret->base_addr[(n2-n1)*stride] = last1;
+  GFC_ARRAY_ELEM (GFC_REAL_16, ret->base_addr, (n2-n1)*spacing) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(jn) (n2 - 1, x);
-  ret->base_addr[(n2-n1-1)*stride] = last2;
+  GFC_ARRAY_ELEM (GFC_REAL_16, ret->base_addr, (n2-n1-1)*spacing) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -100,9 +100,9 @@ bessel_jn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2, GFC_REAL_16 x
 
   for (i = n2-n1-2; i >= 0; i--)
     {
-      ret->base_addr[i*stride] = x2rev * (i+1+n1) * last2 - last1;
+      GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i) = x2rev * (i+1+n1) * last2 - last1;
       last1 = last2;
-      last2 = ret->base_addr[i*stride];
+      last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i);
     }
 }
 
@@ -118,16 +118,16 @@ bessel_yn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2,
 			 GFC_REAL_16 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_16 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_16));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_16));
       ret->offset = 0;
     }
@@ -141,27 +141,27 @@ bessel_yn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2,
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       for (i = 0; i <= n2-n1; i++)
 #if defined(GFC_REAL_16_INFINITY)
-        ret->base_addr[i*stride] = -GFC_REAL_16_INFINITY;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i) = -GFC_REAL_16_INFINITY;
 #else
-        ret->base_addr[i*stride] = -GFC_REAL_16_HUGE;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i) = -GFC_REAL_16_HUGE;
 #endif
       return;
     }
 
   last1 = MATHFUNC(yn) (n1, x);
-  ret->base_addr[0] = last1;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, 0) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(yn) (n1 + 1, x);
-  ret->base_addr[1*stride] = last2;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, 1) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -173,14 +173,14 @@ bessel_yn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2,
 #if defined(GFC_REAL_16_INFINITY)
       if (unlikely (last2 == -GFC_REAL_16_INFINITY))
 	{
-	  ret->base_addr[i*stride] = -GFC_REAL_16_INFINITY;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i) = -GFC_REAL_16_INFINITY;
 	}
       else
 #endif
 	{
-	  ret->base_addr[i*stride] = x2rev * (i-1+n1) * last2 - last1;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i) = x2rev * (i-1+n1) * last2 - last1;
 	  last1 = last2;
-	  last2 = ret->base_addr[i*stride];
+	  last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_16, ret, i);
 	}
     }
 }
diff --git a/libgfortran/generated/bessel_r17.c b/libgfortran/generated/bessel_r17.c
index b05bd3479110..d8ecc43e643b 100644
--- a/libgfortran/generated/bessel_r17.c
+++ b/libgfortran/generated/bessel_r17.c
@@ -49,16 +49,16 @@ void
 bessel_jn_r17 (gfc_array_r17 * const restrict ret, int n1, int n2, GFC_REAL_17 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_17 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_17));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_17));
       ret->offset = 0;
     }
@@ -72,24 +72,24 @@ bessel_jn_r17 (gfc_array_r17 * const restrict ret, int n1, int n2, GFC_REAL_17 x
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       ret->base_addr[0] = 1;
       for (i = 1; i <= n2-n1; i++)
-        ret->base_addr[i*stride] = 0;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i) = 0;
       return;
     }
 
   last1 = MATHFUNC(jn) (n2, x);
-  ret->base_addr[(n2-n1)*stride] = last1;
+  GFC_ARRAY_ELEM (GFC_REAL_17, ret->base_addr, (n2-n1)*spacing) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(jn) (n2 - 1, x);
-  ret->base_addr[(n2-n1-1)*stride] = last2;
+  GFC_ARRAY_ELEM (GFC_REAL_17, ret->base_addr, (n2-n1-1)*spacing) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -98,9 +98,9 @@ bessel_jn_r17 (gfc_array_r17 * const restrict ret, int n1, int n2, GFC_REAL_17 x
 
   for (i = n2-n1-2; i >= 0; i--)
     {
-      ret->base_addr[i*stride] = x2rev * (i+1+n1) * last2 - last1;
+      GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i) = x2rev * (i+1+n1) * last2 - last1;
       last1 = last2;
-      last2 = ret->base_addr[i*stride];
+      last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i);
     }
 }
 
@@ -116,16 +116,16 @@ bessel_yn_r17 (gfc_array_r17 * const restrict ret, int n1, int n2,
 			 GFC_REAL_17 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_17 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_17));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_17));
       ret->offset = 0;
     }
@@ -139,27 +139,27 @@ bessel_yn_r17 (gfc_array_r17 * const restrict ret, int n1, int n2,
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       for (i = 0; i <= n2-n1; i++)
 #if defined(GFC_REAL_17_INFINITY)
-        ret->base_addr[i*stride] = -GFC_REAL_17_INFINITY;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i) = -GFC_REAL_17_INFINITY;
 #else
-        ret->base_addr[i*stride] = -GFC_REAL_17_HUGE;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i) = -GFC_REAL_17_HUGE;
 #endif
       return;
     }
 
   last1 = MATHFUNC(yn) (n1, x);
-  ret->base_addr[0] = last1;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, 0) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(yn) (n1 + 1, x);
-  ret->base_addr[1*stride] = last2;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, 1) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -171,14 +171,14 @@ bessel_yn_r17 (gfc_array_r17 * const restrict ret, int n1, int n2,
 #if defined(GFC_REAL_17_INFINITY)
       if (unlikely (last2 == -GFC_REAL_17_INFINITY))
 	{
-	  ret->base_addr[i*stride] = -GFC_REAL_17_INFINITY;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i) = -GFC_REAL_17_INFINITY;
 	}
       else
 #endif
 	{
-	  ret->base_addr[i*stride] = x2rev * (i-1+n1) * last2 - last1;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i) = x2rev * (i-1+n1) * last2 - last1;
 	  last1 = last2;
-	  last2 = ret->base_addr[i*stride];
+	  last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_17, ret, i);
 	}
     }
 }
diff --git a/libgfortran/generated/bessel_r4.c b/libgfortran/generated/bessel_r4.c
index 62e53111f689..ccc2758382ad 100644
--- a/libgfortran/generated/bessel_r4.c
+++ b/libgfortran/generated/bessel_r4.c
@@ -43,16 +43,16 @@ void
 bessel_jn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2, GFC_REAL_4 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_4 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_4));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_4));
       ret->offset = 0;
     }
@@ -66,24 +66,24 @@ bessel_jn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2, GFC_REAL_4 x)
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       ret->base_addr[0] = 1;
       for (i = 1; i <= n2-n1; i++)
-        ret->base_addr[i*stride] = 0;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i) = 0;
       return;
     }
 
   last1 = MATHFUNC(jn) (n2, x);
-  ret->base_addr[(n2-n1)*stride] = last1;
+  GFC_ARRAY_ELEM (GFC_REAL_4, ret->base_addr, (n2-n1)*spacing) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(jn) (n2 - 1, x);
-  ret->base_addr[(n2-n1-1)*stride] = last2;
+  GFC_ARRAY_ELEM (GFC_REAL_4, ret->base_addr, (n2-n1-1)*spacing) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -92,9 +92,9 @@ bessel_jn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2, GFC_REAL_4 x)
 
   for (i = n2-n1-2; i >= 0; i--)
     {
-      ret->base_addr[i*stride] = x2rev * (i+1+n1) * last2 - last1;
+      GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i) = x2rev * (i+1+n1) * last2 - last1;
       last1 = last2;
-      last2 = ret->base_addr[i*stride];
+      last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i);
     }
 }
 
@@ -110,16 +110,16 @@ bessel_yn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2,
 			 GFC_REAL_4 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_4 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_4));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_4));
       ret->offset = 0;
     }
@@ -133,27 +133,27 @@ bessel_yn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2,
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       for (i = 0; i <= n2-n1; i++)
 #if defined(GFC_REAL_4_INFINITY)
-        ret->base_addr[i*stride] = -GFC_REAL_4_INFINITY;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i) = -GFC_REAL_4_INFINITY;
 #else
-        ret->base_addr[i*stride] = -GFC_REAL_4_HUGE;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i) = -GFC_REAL_4_HUGE;
 #endif
       return;
     }
 
   last1 = MATHFUNC(yn) (n1, x);
-  ret->base_addr[0] = last1;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, 0) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(yn) (n1 + 1, x);
-  ret->base_addr[1*stride] = last2;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, 1) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -165,14 +165,14 @@ bessel_yn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2,
 #if defined(GFC_REAL_4_INFINITY)
       if (unlikely (last2 == -GFC_REAL_4_INFINITY))
 	{
-	  ret->base_addr[i*stride] = -GFC_REAL_4_INFINITY;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i) = -GFC_REAL_4_INFINITY;
 	}
       else
 #endif
 	{
-	  ret->base_addr[i*stride] = x2rev * (i-1+n1) * last2 - last1;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i) = x2rev * (i-1+n1) * last2 - last1;
 	  last1 = last2;
-	  last2 = ret->base_addr[i*stride];
+	  last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_4, ret, i);
 	}
     }
 }
diff --git a/libgfortran/generated/bessel_r8.c b/libgfortran/generated/bessel_r8.c
index 50388275f540..cd482be535e7 100644
--- a/libgfortran/generated/bessel_r8.c
+++ b/libgfortran/generated/bessel_r8.c
@@ -43,16 +43,16 @@ void
 bessel_jn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2, GFC_REAL_8 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_8 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_8));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_8));
       ret->offset = 0;
     }
@@ -66,24 +66,24 @@ bessel_jn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2, GFC_REAL_8 x)
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       ret->base_addr[0] = 1;
       for (i = 1; i <= n2-n1; i++)
-        ret->base_addr[i*stride] = 0;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i) = 0;
       return;
     }
 
   last1 = MATHFUNC(jn) (n2, x);
-  ret->base_addr[(n2-n1)*stride] = last1;
+  GFC_ARRAY_ELEM (GFC_REAL_8, ret->base_addr, (n2-n1)*spacing) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(jn) (n2 - 1, x);
-  ret->base_addr[(n2-n1-1)*stride] = last2;
+  GFC_ARRAY_ELEM (GFC_REAL_8, ret->base_addr, (n2-n1-1)*spacing) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -92,9 +92,9 @@ bessel_jn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2, GFC_REAL_8 x)
 
   for (i = n2-n1-2; i >= 0; i--)
     {
-      ret->base_addr[i*stride] = x2rev * (i+1+n1) * last2 - last1;
+      GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i) = x2rev * (i+1+n1) * last2 - last1;
       last1 = last2;
-      last2 = ret->base_addr[i*stride];
+      last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i);
     }
 }
 
@@ -110,16 +110,16 @@ bessel_yn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2,
 			 GFC_REAL_8 x)
 {
   int i;
-  index_type stride;
+  index_type spacing;
 
   GFC_REAL_8 last1, last2, x2rev;
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (ret->base_addr == NULL)
     {
       size_t size = n2 < n1 ? 0 : n2-n1+1; 
-      GFC_DIMENSION_SET(ret->dim[0], 0, size-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(ret, 0, 0, size-1, sizeof (GFC_REAL_8));
       ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_8));
       ret->offset = 0;
     }
@@ -133,27 +133,27 @@ bessel_yn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2,
 		  "(%ld vs. %ld)", (long int) n2-n1,
 		  (long int) GFC_DESCRIPTOR_EXTENT(ret,0));
 
-  stride = GFC_DESCRIPTOR_STRIDE(ret,0);
+  spacing = GFC_DESCRIPTOR_SPACING(ret,0);
 
   if (unlikely (x == 0))
     {
       for (i = 0; i <= n2-n1; i++)
 #if defined(GFC_REAL_8_INFINITY)
-        ret->base_addr[i*stride] = -GFC_REAL_8_INFINITY;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i) = -GFC_REAL_8_INFINITY;
 #else
-        ret->base_addr[i*stride] = -GFC_REAL_8_HUGE;
+	GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i) = -GFC_REAL_8_HUGE;
 #endif
       return;
     }
 
   last1 = MATHFUNC(yn) (n1, x);
-  ret->base_addr[0] = last1;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, 0) = last1;
 
   if (n1 == n2)
     return;
 
   last2 = MATHFUNC(yn) (n1 + 1, x);
-  ret->base_addr[1*stride] = last2;
+  GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, 1) = last2;
 
   if (n1 + 1 == n2)
     return;
@@ -165,14 +165,14 @@ bessel_yn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2,
 #if defined(GFC_REAL_8_INFINITY)
       if (unlikely (last2 == -GFC_REAL_8_INFINITY))
 	{
-	  ret->base_addr[i*stride] = -GFC_REAL_8_INFINITY;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i) = -GFC_REAL_8_INFINITY;
 	}
       else
 #endif
 	{
-	  ret->base_addr[i*stride] = x2rev * (i-1+n1) * last2 - last1;
+	  GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i) = x2rev * (i-1+n1) * last2 - last1;
 	  last1 = last2;
-	  last2 = ret->base_addr[i*stride];
+	  last2 = GFC_DESCRIPTOR1_ELEM (GFC_REAL_8, ret, i);
 	}
     }
 }
diff --git a/libgfortran/generated/count_16_l.c b/libgfortran/generated/count_16_l.c
index b6406e690d2f..df45696587d2 100644
--- a/libgfortran/generated/count_16_l.c
+++ b/libgfortran/generated/count_16_l.c
@@ -40,8 +40,8 @@ count_16_l (gfc_array_i16 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_INTEGER_16 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ count_16_l (gfc_array_i16 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ count_16_l (gfc_array_i16 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ count_16_l (gfc_array_i16 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_16);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ count_16_l (gfc_array_i16 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -177,8 +176,8 @@ count_16_l (gfc_array_i16 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -187,8 +186,8 @@ count_16_l (gfc_array_i16 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_INTEGER_16*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -199,8 +198,8 @@ count_16_l (gfc_array_i16 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_INTEGER_16*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/count_1_l.c b/libgfortran/generated/count_1_l.c
index 475d6d11c068..32e572a0761e 100644
--- a/libgfortran/generated/count_1_l.c
+++ b/libgfortran/generated/count_1_l.c
@@ -40,8 +40,8 @@ count_1_l (gfc_array_i1 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_INTEGER_1 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ count_1_l (gfc_array_i1 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ count_1_l (gfc_array_i1 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ count_1_l (gfc_array_i1 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_1);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_1));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ count_1_l (gfc_array_i1 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -177,8 +176,8 @@ count_1_l (gfc_array_i1 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_INTEGER_1*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -187,8 +186,8 @@ count_1_l (gfc_array_i1 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_INTEGER_1*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -199,8 +198,8 @@ count_1_l (gfc_array_i1 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_INTEGER_1*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/count_2_l.c b/libgfortran/generated/count_2_l.c
index 1ef08132512c..2341a7481f8c 100644
--- a/libgfortran/generated/count_2_l.c
+++ b/libgfortran/generated/count_2_l.c
@@ -40,8 +40,8 @@ count_2_l (gfc_array_i2 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_INTEGER_2 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ count_2_l (gfc_array_i2 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ count_2_l (gfc_array_i2 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ count_2_l (gfc_array_i2 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_2);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_2));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ count_2_l (gfc_array_i2 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -177,8 +176,8 @@ count_2_l (gfc_array_i2 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_INTEGER_2*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -187,8 +186,8 @@ count_2_l (gfc_array_i2 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_INTEGER_2*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -199,8 +198,8 @@ count_2_l (gfc_array_i2 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_INTEGER_2*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/count_4_l.c b/libgfortran/generated/count_4_l.c
index 4b4f5b046dac..996931892ac1 100644
--- a/libgfortran/generated/count_4_l.c
+++ b/libgfortran/generated/count_4_l.c
@@ -40,8 +40,8 @@ count_4_l (gfc_array_i4 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_INTEGER_4 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ count_4_l (gfc_array_i4 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ count_4_l (gfc_array_i4 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ count_4_l (gfc_array_i4 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_4);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ count_4_l (gfc_array_i4 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -177,8 +176,8 @@ count_4_l (gfc_array_i4 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -187,8 +186,8 @@ count_4_l (gfc_array_i4 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_INTEGER_4*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -199,8 +198,8 @@ count_4_l (gfc_array_i4 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_INTEGER_4*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/count_8_l.c b/libgfortran/generated/count_8_l.c
index e58370c3d651..3a1f8d81ffe5 100644
--- a/libgfortran/generated/count_8_l.c
+++ b/libgfortran/generated/count_8_l.c
@@ -40,8 +40,8 @@ count_8_l (gfc_array_i8 * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride[GFC_MAX_DIMENSIONS];
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type dspacing[GFC_MAX_DIMENSIONS];
   const GFC_LOGICAL_1 * restrict base;
   GFC_INTEGER_8 * restrict dest;
   index_type rank;
@@ -62,11 +62,11 @@ count_8_l (gfc_array_i8 * const restrict retarray,
   if (len < 0)
     len = 0;
 
-  delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+  delta = GFC_DESCRIPTOR_SPACING(array,dim);
 
   for (n = 0; n < dim; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
 
       if (extent[n] < 0)
@@ -74,7 +74,7 @@ count_8_l (gfc_array_i8 * const restrict retarray,
     }
   for (n = dim; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n + 1);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
 
       if (extent[n] < 0)
@@ -88,20 +88,19 @@ count_8_l (gfc_array_i8 * const restrict retarray,
       for (n = 0; n < rank; n++)
         {
           if (n == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_8);
           else
-            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
-
-	  GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
+            str = GFC_DESCRIPTOR_SPACING(retarray,n-1) * extent[n-1];
 
+	  GFC_DESCRIPTOR_DIMENSION_SET(retarray, n, 0, extent[n] - 1, str);
         }
 
       retarray->offset = 0;
       retarray->dtype.rank = rank;
 
-      alloc_size = GFC_DESCRIPTOR_STRIDE(retarray,rank-1) * extent[rank-1];
+      alloc_size = GFC_DESCRIPTOR_SPACING(retarray,rank-1) * extent[rank-1];
 
-      retarray->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8));
+      retarray->base_addr = xmalloc (alloc_size);
       if (alloc_size == 0)
 	return;
     }
@@ -132,7 +131,7 @@ count_8_l (gfc_array_i8 * const restrict retarray,
   for (n = 0; n < rank; n++)
     {
       count[n] = 0;
-      dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
+      dspacing[n] = GFC_DESCRIPTOR_SPACING(retarray,n);
       if (extent[n] <= 0)
 	return;
     }
@@ -177,8 +176,8 @@ count_8_l (gfc_array_i8 * const restrict retarray,
       }
       /* Advance to the next element.  */
       count[0]++;
-      base += sstride[0];
-      dest += dstride[0];
+      base += sspacing[0];
+      dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[0]);
       n = 0;
       while (count[n] == extent[n])
         {
@@ -187,8 +186,8 @@ count_8_l (gfc_array_i8 * const restrict retarray,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          base -= sstride[n] * extent[n];
-          dest -= dstride[n] * extent[n];
+          base -=  sspacing[n] * extent[n];
+          dest = (GFC_INTEGER_8*) (((char*)dest) - dspacing[n] * extent[n]);
           n++;
           if (n >= rank)
             {
@@ -199,8 +198,8 @@ count_8_l (gfc_array_i8 * const restrict retarray,
           else
             {
               count[n]++;
-              base += sstride[n];
-              dest += dstride[n];
+              base += sspacing[n];
+              dest = (GFC_INTEGER_8*) (((char*)dest) + dspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_c10.c b/libgfortran/generated/cshift0_c10.c
index 41a9935ecb07..4a401d48bf3e 100644
--- a/libgfortran/generated/cshift0_c10.c
+++ b/libgfortran/generated/cshift0_c10.c
@@ -66,8 +66,8 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_10);
+  a_ex = sizeof (GFC_COMPLEX_10);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_COMPLEX_10);
+      soffset = sizeof (GFC_COMPLEX_10);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_10) && roffset == sizeof (GFC_COMPLEX_10))
 	{
 	  size_t len1 = shift * sizeof (GFC_COMPLEX_10);
 	  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_10);
@@ -190,25 +183,25 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_COMPLEX_10 *dest = rptr;
-	  const GFC_COMPLEX_10 *src = &sptr[shift * soffset];
+	  const GFC_COMPLEX_10 *src = (GFC_COMPLEX_10*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_COMPLEX_10*) (((char*)dest)  + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_10*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rstride0);
+      sptr = (GFC_COMPLEX_10*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_COMPLEX_10*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_COMPLEX_10*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_COMPLEX_10*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_c16.c b/libgfortran/generated/cshift0_c16.c
index aa9b038ffa9c..7d589809a280 100644
--- a/libgfortran/generated/cshift0_c16.c
+++ b/libgfortran/generated/cshift0_c16.c
@@ -66,8 +66,8 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_16);
+  a_ex = sizeof (GFC_COMPLEX_16);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_COMPLEX_16);
+      soffset = sizeof (GFC_COMPLEX_16);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_16) && roffset == sizeof (GFC_COMPLEX_16))
 	{
 	  size_t len1 = shift * sizeof (GFC_COMPLEX_16);
 	  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_16);
@@ -190,25 +183,25 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_COMPLEX_16 *dest = rptr;
-	  const GFC_COMPLEX_16 *src = &sptr[shift * soffset];
+	  const GFC_COMPLEX_16 *src = (GFC_COMPLEX_16*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_COMPLEX_16*) (((char*)dest)  + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_16*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rstride0);
+      sptr = (GFC_COMPLEX_16*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_COMPLEX_16*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_COMPLEX_16*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_COMPLEX_16*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_c17.c b/libgfortran/generated/cshift0_c17.c
index 93f9b2e4dd5f..7c672f693135 100644
--- a/libgfortran/generated/cshift0_c17.c
+++ b/libgfortran/generated/cshift0_c17.c
@@ -66,8 +66,8 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_17);
+  a_ex = sizeof (GFC_COMPLEX_17);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_COMPLEX_17);
+      soffset = sizeof (GFC_COMPLEX_17);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_17) && roffset == sizeof (GFC_COMPLEX_17))
 	{
 	  size_t len1 = shift * sizeof (GFC_COMPLEX_17);
 	  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_17);
@@ -190,25 +183,25 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_COMPLEX_17 *dest = rptr;
-	  const GFC_COMPLEX_17 *src = &sptr[shift * soffset];
+	  const GFC_COMPLEX_17 *src = (GFC_COMPLEX_17*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_COMPLEX_17*) (((char*)dest)  + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_17*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rstride0);
+      sptr = (GFC_COMPLEX_17*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_COMPLEX_17*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_COMPLEX_17*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_COMPLEX_17*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_c4.c b/libgfortran/generated/cshift0_c4.c
index 7583c4fd7713..bf0ee7372bed 100644
--- a/libgfortran/generated/cshift0_c4.c
+++ b/libgfortran/generated/cshift0_c4.c
@@ -66,8 +66,8 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_4);
+  a_ex = sizeof (GFC_COMPLEX_4);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_COMPLEX_4);
+      soffset = sizeof (GFC_COMPLEX_4);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_4) && roffset == sizeof (GFC_COMPLEX_4))
 	{
 	  size_t len1 = shift * sizeof (GFC_COMPLEX_4);
 	  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_4);
@@ -190,25 +183,25 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_COMPLEX_4 *dest = rptr;
-	  const GFC_COMPLEX_4 *src = &sptr[shift * soffset];
+	  const GFC_COMPLEX_4 *src = (GFC_COMPLEX_4*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_COMPLEX_4*) (((char*)dest)  + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_4*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rstride0);
+      sptr = (GFC_COMPLEX_4*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_COMPLEX_4*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_COMPLEX_4*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_COMPLEX_4*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_c8.c b/libgfortran/generated/cshift0_c8.c
index b7a9b65c1dfa..e1991fc835a8 100644
--- a/libgfortran/generated/cshift0_c8.c
+++ b/libgfortran/generated/cshift0_c8.c
@@ -66,8 +66,8 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_COMPLEX_8);
+  a_ex = sizeof (GFC_COMPLEX_8);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_COMPLEX_8);
+      soffset = sizeof (GFC_COMPLEX_8);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_8) && roffset == sizeof (GFC_COMPLEX_8))
 	{
 	  size_t len1 = shift * sizeof (GFC_COMPLEX_8);
 	  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_8);
@@ -190,25 +183,25 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_COMPLEX_8 *dest = rptr;
-	  const GFC_COMPLEX_8 *src = &sptr[shift * soffset];
+	  const GFC_COMPLEX_8 *src = (GFC_COMPLEX_8*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_COMPLEX_8*) (((char*)dest)  + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_8*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rstride0);
+      sptr = (GFC_COMPLEX_8*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_COMPLEX_8*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_COMPLEX_8*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_COMPLEX_8*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_i1.c b/libgfortran/generated/cshift0_i1.c
index 36f95ec2640f..a1797577772a 100644
--- a/libgfortran/generated/cshift0_i1.c
+++ b/libgfortran/generated/cshift0_i1.c
@@ -66,8 +66,8 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_1);
+  a_ex = sizeof (GFC_INTEGER_1);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_INTEGER_1);
+      soffset = sizeof (GFC_INTEGER_1);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_1) && roffset == sizeof (GFC_INTEGER_1))
 	{
 	  size_t len1 = shift * sizeof (GFC_INTEGER_1);
 	  size_t len2 = (len - shift) * sizeof (GFC_INTEGER_1);
@@ -190,25 +183,25 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_INTEGER_1 *dest = rptr;
-	  const GFC_INTEGER_1 *src = &sptr[shift * soffset];
+	  const GFC_INTEGER_1 *src = (GFC_INTEGER_1*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_INTEGER_1*) (((char*)dest)  + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_1*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_INTEGER_1*) (((char*)rptr) + rstride0);
+      sptr = (GFC_INTEGER_1*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_INTEGER_1*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_INTEGER_1*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_INTEGER_1*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_INTEGER_1*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_i16.c b/libgfortran/generated/cshift0_i16.c
index 1d65186576d1..8632ce5c27ad 100644
--- a/libgfortran/generated/cshift0_i16.c
+++ b/libgfortran/generated/cshift0_i16.c
@@ -66,8 +66,8 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_16);
+  a_ex = sizeof (GFC_INTEGER_16);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_INTEGER_16);
+      soffset = sizeof (GFC_INTEGER_16);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_16) && roffset == sizeof (GFC_INTEGER_16))
 	{
 	  size_t len1 = shift * sizeof (GFC_INTEGER_16);
 	  size_t len2 = (len - shift) * sizeof (GFC_INTEGER_16);
@@ -190,25 +183,25 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_INTEGER_16 *dest = rptr;
-	  const GFC_INTEGER_16 *src = &sptr[shift * soffset];
+	  const GFC_INTEGER_16 *src = (GFC_INTEGER_16*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_INTEGER_16*) (((char*)dest)  + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_16*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_INTEGER_16*) (((char*)rptr) + rstride0);
+      sptr = (GFC_INTEGER_16*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_INTEGER_16*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_INTEGER_16*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_INTEGER_16*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_INTEGER_16*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_i2.c b/libgfortran/generated/cshift0_i2.c
index 838a7a4e594e..694f3d0c02f8 100644
--- a/libgfortran/generated/cshift0_i2.c
+++ b/libgfortran/generated/cshift0_i2.c
@@ -66,8 +66,8 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_2);
+  a_ex = sizeof (GFC_INTEGER_2);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_INTEGER_2);
+      soffset = sizeof (GFC_INTEGER_2);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_2) && roffset == sizeof (GFC_INTEGER_2))
 	{
 	  size_t len1 = shift * sizeof (GFC_INTEGER_2);
 	  size_t len2 = (len - shift) * sizeof (GFC_INTEGER_2);
@@ -190,25 +183,25 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_INTEGER_2 *dest = rptr;
-	  const GFC_INTEGER_2 *src = &sptr[shift * soffset];
+	  const GFC_INTEGER_2 *src = (GFC_INTEGER_2*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_INTEGER_2*) (((char*)dest)  + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_2*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_INTEGER_2*) (((char*)rptr) + rstride0);
+      sptr = (GFC_INTEGER_2*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_INTEGER_2*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_INTEGER_2*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_INTEGER_2*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_INTEGER_2*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_i4.c b/libgfortran/generated/cshift0_i4.c
index 17236b5fcbc5..dd076ba40264 100644
--- a/libgfortran/generated/cshift0_i4.c
+++ b/libgfortran/generated/cshift0_i4.c
@@ -66,8 +66,8 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_4);
+  a_ex = sizeof (GFC_INTEGER_4);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_INTEGER_4);
+      soffset = sizeof (GFC_INTEGER_4);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_4) && roffset == sizeof (GFC_INTEGER_4))
 	{
 	  size_t len1 = shift * sizeof (GFC_INTEGER_4);
 	  size_t len2 = (len - shift) * sizeof (GFC_INTEGER_4);
@@ -190,25 +183,25 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_INTEGER_4 *dest = rptr;
-	  const GFC_INTEGER_4 *src = &sptr[shift * soffset];
+	  const GFC_INTEGER_4 *src = (GFC_INTEGER_4*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_INTEGER_4*) (((char*)dest)  + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_4*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_INTEGER_4*) (((char*)rptr) + rstride0);
+      sptr = (GFC_INTEGER_4*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_INTEGER_4*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_INTEGER_4*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_INTEGER_4*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_INTEGER_4*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_i8.c b/libgfortran/generated/cshift0_i8.c
index 980663155c65..40bc33cb5d3a 100644
--- a/libgfortran/generated/cshift0_i8.c
+++ b/libgfortran/generated/cshift0_i8.c
@@ -66,8 +66,8 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_INTEGER_8);
+  a_ex = sizeof (GFC_INTEGER_8);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_INTEGER_8);
+      soffset = sizeof (GFC_INTEGER_8);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_8) && roffset == sizeof (GFC_INTEGER_8))
 	{
 	  size_t len1 = shift * sizeof (GFC_INTEGER_8);
 	  size_t len2 = (len - shift) * sizeof (GFC_INTEGER_8);
@@ -190,25 +183,25 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_INTEGER_8 *dest = rptr;
-	  const GFC_INTEGER_8 *src = &sptr[shift * soffset];
+	  const GFC_INTEGER_8 *src = (GFC_INTEGER_8*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_INTEGER_8*) (((char*)dest)  + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_8*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_INTEGER_8*) (((char*)rptr) + rstride0);
+      sptr = (GFC_INTEGER_8*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_INTEGER_8*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_INTEGER_8*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_INTEGER_8*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_INTEGER_8*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_r10.c b/libgfortran/generated/cshift0_r10.c
index 941d6ca9ff28..903ee1d3e00a 100644
--- a/libgfortran/generated/cshift0_r10.c
+++ b/libgfortran/generated/cshift0_r10.c
@@ -66,8 +66,8 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_10);
+  a_ex = sizeof (GFC_REAL_10);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_REAL_10);
+      soffset = sizeof (GFC_REAL_10);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_10) && roffset == sizeof (GFC_REAL_10))
 	{
 	  size_t len1 = shift * sizeof (GFC_REAL_10);
 	  size_t len2 = (len - shift) * sizeof (GFC_REAL_10);
@@ -190,25 +183,25 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_REAL_10 *dest = rptr;
-	  const GFC_REAL_10 *src = &sptr[shift * soffset];
+	  const GFC_REAL_10 *src = (GFC_REAL_10*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_REAL_10*) (((char*)dest)  + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_10*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_REAL_10*) (((char*)rptr) + rstride0);
+      sptr = (GFC_REAL_10*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_REAL_10*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_REAL_10*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_REAL_10*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_REAL_10*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_r16.c b/libgfortran/generated/cshift0_r16.c
index 8aac5b0298ef..b2237bd776a3 100644
--- a/libgfortran/generated/cshift0_r16.c
+++ b/libgfortran/generated/cshift0_r16.c
@@ -66,8 +66,8 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_16);
+  a_ex = sizeof (GFC_REAL_16);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_REAL_16);
+      soffset = sizeof (GFC_REAL_16);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_16) && roffset == sizeof (GFC_REAL_16))
 	{
 	  size_t len1 = shift * sizeof (GFC_REAL_16);
 	  size_t len2 = (len - shift) * sizeof (GFC_REAL_16);
@@ -190,25 +183,25 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_REAL_16 *dest = rptr;
-	  const GFC_REAL_16 *src = &sptr[shift * soffset];
+	  const GFC_REAL_16 *src = (GFC_REAL_16*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_REAL_16*) (((char*)dest)  + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_16*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_REAL_16*) (((char*)rptr) + rstride0);
+      sptr = (GFC_REAL_16*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_REAL_16*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_REAL_16*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_REAL_16*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_REAL_16*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_r17.c b/libgfortran/generated/cshift0_r17.c
index 0288573797bd..2a5314701b76 100644
--- a/libgfortran/generated/cshift0_r17.c
+++ b/libgfortran/generated/cshift0_r17.c
@@ -66,8 +66,8 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_17);
+  a_ex = sizeof (GFC_REAL_17);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_REAL_17);
+      soffset = sizeof (GFC_REAL_17);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_17) && roffset == sizeof (GFC_REAL_17))
 	{
 	  size_t len1 = shift * sizeof (GFC_REAL_17);
 	  size_t len2 = (len - shift) * sizeof (GFC_REAL_17);
@@ -190,25 +183,25 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_REAL_17 *dest = rptr;
-	  const GFC_REAL_17 *src = &sptr[shift * soffset];
+	  const GFC_REAL_17 *src = (GFC_REAL_17*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_REAL_17*) (((char*)dest)  + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_17*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_REAL_17*) (((char*)rptr) + rstride0);
+      sptr = (GFC_REAL_17*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_REAL_17*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_REAL_17*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_r17 (gfc_array_r17 *ret, const gfc_array_r17 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_REAL_17*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_REAL_17*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_r4.c b/libgfortran/generated/cshift0_r4.c
index 5acddeb37b27..5cf9c327fb3a 100644
--- a/libgfortran/generated/cshift0_r4.c
+++ b/libgfortran/generated/cshift0_r4.c
@@ -66,8 +66,8 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_4);
+  a_ex = sizeof (GFC_REAL_4);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_REAL_4);
+      soffset = sizeof (GFC_REAL_4);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_4) && roffset == sizeof (GFC_REAL_4))
 	{
 	  size_t len1 = shift * sizeof (GFC_REAL_4);
 	  size_t len2 = (len - shift) * sizeof (GFC_REAL_4);
@@ -190,25 +183,25 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_REAL_4 *dest = rptr;
-	  const GFC_REAL_4 *src = &sptr[shift * soffset];
+	  const GFC_REAL_4 *src = (GFC_REAL_4*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_REAL_4*) (((char*)dest)  + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_4*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_REAL_4*) (((char*)rptr) + rstride0);
+      sptr = (GFC_REAL_4*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_REAL_4*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_REAL_4*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_REAL_4*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_REAL_4*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift0_r8.c b/libgfortran/generated/cshift0_r8.c
index e6dbbd66c3b9..f83873b6dc08 100644
--- a/libgfortran/generated/cshift0_r8.c
+++ b/libgfortran/generated/cshift0_r8.c
@@ -66,8 +66,8 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
   soffset = 1;
   len = 0;
 
-  r_ex = 1;
-  a_ex = 1;
+  r_ex = sizeof (GFC_REAL_8);
+  a_ex = sizeof (GFC_REAL_8);
 
   if (which > 0)
     {
@@ -77,13 +77,13 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
       for (n = 0; n < dim; n ++)
 	{
 	  index_type rs, as;
-	  rs = GFC_DESCRIPTOR_STRIDE (ret, n);
+	  rs = GFC_DESCRIPTOR_SPACING (ret, n);
 	  if (rs != r_ex)
 	    {
 	      do_blocked = false;
 	      break;
 	    }
-	  as = GFC_DESCRIPTOR_STRIDE (array, n);
+	  as = GFC_DESCRIPTOR_SPACING (array, n);
 	  if (as != a_ex)
 	    {
 	      do_blocked = false;
@@ -111,10 +111,10 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
 	 bn = cshift(a,sh*n1*n2,1)
 
 	 we can used a more blocked algorithm for dim>1.  */
-      sstride[0] = 1;
-      rstride[0] = 1;
-      roffset = 1;
-      soffset = 1;
+      sstride[0] = 0;
+      rstride[0] = 0;
+      roffset = sizeof (GFC_REAL_8);
+      soffset = sizeof (GFC_REAL_8);
       len = GFC_DESCRIPTOR_STRIDE(array, which)
 	* GFC_DESCRIPTOR_EXTENT(array, which);      
       shift *= GFC_DESCRIPTOR_STRIDE(array, which);
@@ -122,10 +122,11 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
 	{
 	  count[n] = 0;
 	  extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	  rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	  sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	  rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	  sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	  n++;
 	}
+
       dim = GFC_DESCRIPTOR_RANK (array) - which;
     }
   else
@@ -134,27 +135,19 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
 	{
 	  if (dim == which)
 	    {
-	      roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      if (roffset == 0)
-		roffset = 1;
-	      soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-	      if (soffset == 0)
-		soffset = 1;
+	      roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      soffset = GFC_DESCRIPTOR_SPACING(array,dim);
 	      len = GFC_DESCRIPTOR_EXTENT(array,dim);
 	    }
 	  else
 	    {
 	      count[n] = 0;
 	      extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-	      rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-	      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
+	      rstride[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+	      sstride[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 	      n++;
 	    }
 	}
-      if (sstride[0] == 0)
-	sstride[0] = 1;
-      if (rstride[0] == 0)
-	rstride[0] = 1;
 
       dim = GFC_DESCRIPTOR_RANK (array);
     }
@@ -178,7 +171,7 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
 
       /* If elements are contiguous, perform the operation
 	 in two block moves.  */
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_8) && roffset == sizeof (GFC_REAL_8))
 	{
 	  size_t len1 = shift * sizeof (GFC_REAL_8);
 	  size_t len2 = (len - shift) * sizeof (GFC_REAL_8);
@@ -190,25 +183,25 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
 	  /* Otherwise, we will have to perform the copy one element at
 	     a time.  */
 	  GFC_REAL_8 *dest = rptr;
-	  const GFC_REAL_8 *src = &sptr[shift * soffset];
+	  const GFC_REAL_8 *src = (GFC_REAL_8*) (((char*)sptr) + shift * soffset);
 
 	  for (n = 0; n < len - shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest  =  (GFC_REAL_8*) (((char*)dest)  + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < shift; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_8*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
+      rptr = (GFC_REAL_8*) (((char*)rptr) + rstride0);
+      sptr = (GFC_REAL_8*) (((char*)sptr) + sstride0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -218,8 +211,8 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
+          rptr = (GFC_REAL_8*) (((char*)rptr) - rstride[n] * extent[n]);
+          sptr = (GFC_REAL_8*) (((char*)sptr) - sstride[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -230,8 +223,8 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
+              rptr = (GFC_REAL_8*) (((char*)rptr) + rstride[n]);
+              sptr = (GFC_REAL_8*) (((char*)sptr) + sstride[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16.c b/libgfortran/generated/cshift1_16.c
index 6b3653d235bf..9ffdbcd8efac 100644
--- a/libgfortran/generated/cshift1_16.c
+++ b/libgfortran/generated/cshift1_16.c
@@ -36,20 +36,20 @@ cshift1 (gfc_array_char * const restrict ret,
 	const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -87,12 +87,12 @@ cshift1 (gfc_array_char * const restrict ret,
           ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_16);
           else
 	    str = GFC_DESCRIPTOR_EXTENT(ret,i-1) *
-	      GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
         }
     }
   else if (unlikely (compile_options.bounds_check))
@@ -214,36 +214,26 @@ cshift1 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -289,9 +279,9 @@ cshift1 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (GFC_INTEGER_16*) (((char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -301,9 +291,9 @@ cshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (GFC_INTEGER_16*) (((char*)hptr) - hspacing[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -314,9 +304,9 @@ cshift1 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (GFC_INTEGER_16*) (((char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_c10.c b/libgfortran/generated/cshift1_16_c10.c
index fc31e697fcde..e77ac33d7d4b 100644
--- a/libgfortran/generated/cshift1_16_c10.c
+++ b/libgfortran/generated/cshift1_16_c10.c
@@ -35,20 +35,20 @@ cshift1_16_c10 (gfc_array_c10 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_10 *rptr;
   GFC_COMPLEX_10 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_10 *sptr;
   const GFC_COMPLEX_10 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_c10 (gfc_array_c10 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_c10 (gfc_array_c10 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_10*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_10) && roffset == sizeof (GFC_COMPLEX_10))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_10);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_10);
@@ -147,21 +137,21 @@ cshift1_16_c10 (gfc_array_c10 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_10*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_10*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_c10 (gfc_array_c10 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_10*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_c10 (gfc_array_c10 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_c16.c b/libgfortran/generated/cshift1_16_c16.c
index f5d7b68b26fd..971bae08fd3c 100644
--- a/libgfortran/generated/cshift1_16_c16.c
+++ b/libgfortran/generated/cshift1_16_c16.c
@@ -35,20 +35,20 @@ cshift1_16_c16 (gfc_array_c16 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_16 *rptr;
   GFC_COMPLEX_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_16 *sptr;
   const GFC_COMPLEX_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_c16 (gfc_array_c16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_c16 (gfc_array_c16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_16) && roffset == sizeof (GFC_COMPLEX_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_16);
@@ -147,21 +137,21 @@ cshift1_16_c16 (gfc_array_c16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_16*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_16*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_c16 (gfc_array_c16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_c16 (gfc_array_c16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_c17.c b/libgfortran/generated/cshift1_16_c17.c
index 689da3fd3363..6497b6dc0a04 100644
--- a/libgfortran/generated/cshift1_16_c17.c
+++ b/libgfortran/generated/cshift1_16_c17.c
@@ -35,20 +35,20 @@ cshift1_16_c17 (gfc_array_c17 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_17 *rptr;
   GFC_COMPLEX_17 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_17 *sptr;
   const GFC_COMPLEX_17 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_c17 (gfc_array_c17 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_c17 (gfc_array_c17 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_17*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_17) && roffset == sizeof (GFC_COMPLEX_17))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_17);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_17);
@@ -147,21 +137,21 @@ cshift1_16_c17 (gfc_array_c17 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_17*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_17*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_c17 (gfc_array_c17 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_17*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_c17 (gfc_array_c17 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_c4.c b/libgfortran/generated/cshift1_16_c4.c
index df7adbb3c3bd..3001d1e78750 100644
--- a/libgfortran/generated/cshift1_16_c4.c
+++ b/libgfortran/generated/cshift1_16_c4.c
@@ -35,20 +35,20 @@ cshift1_16_c4 (gfc_array_c4 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_4 *rptr;
   GFC_COMPLEX_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_4 *sptr;
   const GFC_COMPLEX_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_c4 (gfc_array_c4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_c4 (gfc_array_c4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_4) && roffset == sizeof (GFC_COMPLEX_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_4);
@@ -147,21 +137,21 @@ cshift1_16_c4 (gfc_array_c4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_4*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_4*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_c4 (gfc_array_c4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_c4 (gfc_array_c4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_c8.c b/libgfortran/generated/cshift1_16_c8.c
index ea0a3ef00d55..295490b8d200 100644
--- a/libgfortran/generated/cshift1_16_c8.c
+++ b/libgfortran/generated/cshift1_16_c8.c
@@ -35,20 +35,20 @@ cshift1_16_c8 (gfc_array_c8 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_8 *rptr;
   GFC_COMPLEX_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_8 *sptr;
   const GFC_COMPLEX_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_c8 (gfc_array_c8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_c8 (gfc_array_c8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_8) && roffset == sizeof (GFC_COMPLEX_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_8);
@@ -147,21 +137,21 @@ cshift1_16_c8 (gfc_array_c8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_8*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_8*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_c8 (gfc_array_c8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_c8 (gfc_array_c8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_i1.c b/libgfortran/generated/cshift1_16_i1.c
index adb09917000a..342bf5f2337b 100644
--- a/libgfortran/generated/cshift1_16_i1.c
+++ b/libgfortran/generated/cshift1_16_i1.c
@@ -35,20 +35,20 @@ cshift1_16_i1 (gfc_array_i1 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_1 *rptr;
   GFC_INTEGER_1 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_1 *sptr;
   const GFC_INTEGER_1 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_i1 (gfc_array_i1 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_i1 (gfc_array_i1 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_1*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_1) && roffset == sizeof (GFC_INTEGER_1))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_1);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_1);
@@ -147,21 +137,21 @@ cshift1_16_i1 (gfc_array_i1 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_1*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_1*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_1*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_1*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_i1 (gfc_array_i1 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_1*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_1*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_i1 (gfc_array_i1 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_1*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_1*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_i16.c b/libgfortran/generated/cshift1_16_i16.c
index 5f0ed71f8cab..0a9cf5c1b399 100644
--- a/libgfortran/generated/cshift1_16_i16.c
+++ b/libgfortran/generated/cshift1_16_i16.c
@@ -35,20 +35,20 @@ cshift1_16_i16 (gfc_array_i16 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_16 *rptr;
   GFC_INTEGER_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_16 *sptr;
   const GFC_INTEGER_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_i16 (gfc_array_i16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_i16 (gfc_array_i16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_16) && roffset == sizeof (GFC_INTEGER_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_16);
@@ -147,21 +137,21 @@ cshift1_16_i16 (gfc_array_i16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_16*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_16*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_i16 (gfc_array_i16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_i16 (gfc_array_i16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_i2.c b/libgfortran/generated/cshift1_16_i2.c
index c144c67bf95b..411ef3690c5c 100644
--- a/libgfortran/generated/cshift1_16_i2.c
+++ b/libgfortran/generated/cshift1_16_i2.c
@@ -35,20 +35,20 @@ cshift1_16_i2 (gfc_array_i2 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_2 *rptr;
   GFC_INTEGER_2 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_2 *sptr;
   const GFC_INTEGER_2 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_i2 (gfc_array_i2 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_i2 (gfc_array_i2 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_2*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_2) && roffset == sizeof (GFC_INTEGER_2))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_2);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_2);
@@ -147,21 +137,21 @@ cshift1_16_i2 (gfc_array_i2 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_2*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_2*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_2*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_2*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_i2 (gfc_array_i2 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_2*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_2*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_i2 (gfc_array_i2 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_2*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_2*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_i4.c b/libgfortran/generated/cshift1_16_i4.c
index 8572905bf696..bed7162e8564 100644
--- a/libgfortran/generated/cshift1_16_i4.c
+++ b/libgfortran/generated/cshift1_16_i4.c
@@ -35,20 +35,20 @@ cshift1_16_i4 (gfc_array_i4 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_4 *rptr;
   GFC_INTEGER_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_4 *sptr;
   const GFC_INTEGER_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_i4 (gfc_array_i4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_i4 (gfc_array_i4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_4) && roffset == sizeof (GFC_INTEGER_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_4);
@@ -147,21 +137,21 @@ cshift1_16_i4 (gfc_array_i4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_4*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_4*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_i4 (gfc_array_i4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_i4 (gfc_array_i4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_i8.c b/libgfortran/generated/cshift1_16_i8.c
index cd88fd99634c..41fea04eba28 100644
--- a/libgfortran/generated/cshift1_16_i8.c
+++ b/libgfortran/generated/cshift1_16_i8.c
@@ -35,20 +35,20 @@ cshift1_16_i8 (gfc_array_i8 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_8 *rptr;
   GFC_INTEGER_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_8 *sptr;
   const GFC_INTEGER_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_i8 (gfc_array_i8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_i8 (gfc_array_i8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_8) && roffset == sizeof (GFC_INTEGER_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_8);
@@ -147,21 +137,21 @@ cshift1_16_i8 (gfc_array_i8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_8*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_8*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_i8 (gfc_array_i8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_i8 (gfc_array_i8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_r10.c b/libgfortran/generated/cshift1_16_r10.c
index 849441d2e88f..dedce9b179b2 100644
--- a/libgfortran/generated/cshift1_16_r10.c
+++ b/libgfortran/generated/cshift1_16_r10.c
@@ -35,20 +35,20 @@ cshift1_16_r10 (gfc_array_r10 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_10 *rptr;
   GFC_REAL_10 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_10 *sptr;
   const GFC_REAL_10 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_r10 (gfc_array_r10 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_r10 (gfc_array_r10 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_10*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_10) && roffset == sizeof (GFC_REAL_10))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_10);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_10);
@@ -147,21 +137,21 @@ cshift1_16_r10 (gfc_array_r10 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_10*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_10*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_10*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_10*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_r10 (gfc_array_r10 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_10*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_10*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_r10 (gfc_array_r10 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_10*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_10*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_r16.c b/libgfortran/generated/cshift1_16_r16.c
index 22708dcc2fe3..381fedf38154 100644
--- a/libgfortran/generated/cshift1_16_r16.c
+++ b/libgfortran/generated/cshift1_16_r16.c
@@ -35,20 +35,20 @@ cshift1_16_r16 (gfc_array_r16 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_16 *rptr;
   GFC_REAL_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_16 *sptr;
   const GFC_REAL_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_r16 (gfc_array_r16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_r16 (gfc_array_r16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_16) && roffset == sizeof (GFC_REAL_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_16);
@@ -147,21 +137,21 @@ cshift1_16_r16 (gfc_array_r16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_16*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_16*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_r16 (gfc_array_r16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_r16 (gfc_array_r16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_r17.c b/libgfortran/generated/cshift1_16_r17.c
index 8943fafda64a..479f63351f03 100644
--- a/libgfortran/generated/cshift1_16_r17.c
+++ b/libgfortran/generated/cshift1_16_r17.c
@@ -35,20 +35,20 @@ cshift1_16_r17 (gfc_array_r17 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_17 *rptr;
   GFC_REAL_17 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_17 *sptr;
   const GFC_REAL_17 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_r17 (gfc_array_r17 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_r17 (gfc_array_r17 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_17*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_17) && roffset == sizeof (GFC_REAL_17))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_17);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_17);
@@ -147,21 +137,21 @@ cshift1_16_r17 (gfc_array_r17 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_17*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_17*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_17*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_17*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_r17 (gfc_array_r17 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_17*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_17*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_r17 (gfc_array_r17 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_17*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_17*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_r4.c b/libgfortran/generated/cshift1_16_r4.c
index 0763760c0a66..a3e85a84ba77 100644
--- a/libgfortran/generated/cshift1_16_r4.c
+++ b/libgfortran/generated/cshift1_16_r4.c
@@ -35,20 +35,20 @@ cshift1_16_r4 (gfc_array_r4 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_4 *rptr;
   GFC_REAL_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_4 *sptr;
   const GFC_REAL_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_r4 (gfc_array_r4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_r4 (gfc_array_r4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_4) && roffset == sizeof (GFC_REAL_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_4);
@@ -147,21 +137,21 @@ cshift1_16_r4 (gfc_array_r4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_4*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_4*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_r4 (gfc_array_r4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_r4 (gfc_array_r4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_16_r8.c b/libgfortran/generated/cshift1_16_r8.c
index dad13a4f0f38..2b813ba755af 100644
--- a/libgfortran/generated/cshift1_16_r8.c
+++ b/libgfortran/generated/cshift1_16_r8.c
@@ -35,20 +35,20 @@ cshift1_16_r8 (gfc_array_r8 * const restrict ret,
 		const GFC_INTEGER_16 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_8 *rptr;
   GFC_REAL_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_8 *sptr;
   const GFC_REAL_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_16_r8 (gfc_array_r8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_16_r8 (gfc_array_r8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_8) && roffset == sizeof (GFC_REAL_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_8);
@@ -147,21 +137,21 @@ cshift1_16_r8 (gfc_array_r8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_8*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_8*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_16_r8 (gfc_array_r8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_16*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_16_r8 (gfc_array_r8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_16*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4.c b/libgfortran/generated/cshift1_4.c
index e1e039950702..1ebda2699dea 100644
--- a/libgfortran/generated/cshift1_4.c
+++ b/libgfortran/generated/cshift1_4.c
@@ -36,20 +36,20 @@ cshift1 (gfc_array_char * const restrict ret,
 	const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -87,12 +87,12 @@ cshift1 (gfc_array_char * const restrict ret,
           ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_4);
           else
 	    str = GFC_DESCRIPTOR_EXTENT(ret,i-1) *
-	      GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
         }
     }
   else if (unlikely (compile_options.bounds_check))
@@ -214,36 +214,26 @@ cshift1 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -289,9 +279,9 @@ cshift1 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (GFC_INTEGER_4*) (((char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -301,9 +291,9 @@ cshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (GFC_INTEGER_4*) (((char*)hptr) - hspacing[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -314,9 +304,9 @@ cshift1 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (GFC_INTEGER_4*) (((char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_c10.c b/libgfortran/generated/cshift1_4_c10.c
index b89b673080dd..5b7ef1cbfeff 100644
--- a/libgfortran/generated/cshift1_4_c10.c
+++ b/libgfortran/generated/cshift1_4_c10.c
@@ -35,20 +35,20 @@ cshift1_4_c10 (gfc_array_c10 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_10 *rptr;
   GFC_COMPLEX_10 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_10 *sptr;
   const GFC_COMPLEX_10 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_c10 (gfc_array_c10 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_c10 (gfc_array_c10 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_10*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_10) && roffset == sizeof (GFC_COMPLEX_10))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_10);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_10);
@@ -147,21 +137,21 @@ cshift1_4_c10 (gfc_array_c10 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_10*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_10*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_c10 (gfc_array_c10 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_10*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_c10 (gfc_array_c10 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_c16.c b/libgfortran/generated/cshift1_4_c16.c
index 096b3da68b65..80aa0228401c 100644
--- a/libgfortran/generated/cshift1_4_c16.c
+++ b/libgfortran/generated/cshift1_4_c16.c
@@ -35,20 +35,20 @@ cshift1_4_c16 (gfc_array_c16 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_16 *rptr;
   GFC_COMPLEX_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_16 *sptr;
   const GFC_COMPLEX_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_c16 (gfc_array_c16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_c16 (gfc_array_c16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_16) && roffset == sizeof (GFC_COMPLEX_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_16);
@@ -147,21 +137,21 @@ cshift1_4_c16 (gfc_array_c16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_16*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_16*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_c16 (gfc_array_c16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_c16 (gfc_array_c16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_c17.c b/libgfortran/generated/cshift1_4_c17.c
index 03e99bd908f3..4e6741a0b2bb 100644
--- a/libgfortran/generated/cshift1_4_c17.c
+++ b/libgfortran/generated/cshift1_4_c17.c
@@ -35,20 +35,20 @@ cshift1_4_c17 (gfc_array_c17 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_17 *rptr;
   GFC_COMPLEX_17 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_17 *sptr;
   const GFC_COMPLEX_17 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_c17 (gfc_array_c17 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_c17 (gfc_array_c17 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_17*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_17) && roffset == sizeof (GFC_COMPLEX_17))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_17);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_17);
@@ -147,21 +137,21 @@ cshift1_4_c17 (gfc_array_c17 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_17*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_17*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_c17 (gfc_array_c17 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_17*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_c17 (gfc_array_c17 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_c4.c b/libgfortran/generated/cshift1_4_c4.c
index 4a2b656718a8..3667b9dcd2da 100644
--- a/libgfortran/generated/cshift1_4_c4.c
+++ b/libgfortran/generated/cshift1_4_c4.c
@@ -35,20 +35,20 @@ cshift1_4_c4 (gfc_array_c4 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_4 *rptr;
   GFC_COMPLEX_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_4 *sptr;
   const GFC_COMPLEX_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_c4 (gfc_array_c4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_c4 (gfc_array_c4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_4) && roffset == sizeof (GFC_COMPLEX_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_4);
@@ -147,21 +137,21 @@ cshift1_4_c4 (gfc_array_c4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_4*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_4*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_c4 (gfc_array_c4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_c4 (gfc_array_c4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_c8.c b/libgfortran/generated/cshift1_4_c8.c
index 9f52c027e51e..4ac9044683cd 100644
--- a/libgfortran/generated/cshift1_4_c8.c
+++ b/libgfortran/generated/cshift1_4_c8.c
@@ -35,20 +35,20 @@ cshift1_4_c8 (gfc_array_c8 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_8 *rptr;
   GFC_COMPLEX_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_8 *sptr;
   const GFC_COMPLEX_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_c8 (gfc_array_c8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_c8 (gfc_array_c8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_8) && roffset == sizeof (GFC_COMPLEX_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_8);
@@ -147,21 +137,21 @@ cshift1_4_c8 (gfc_array_c8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_8*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_8*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_c8 (gfc_array_c8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_c8 (gfc_array_c8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_i1.c b/libgfortran/generated/cshift1_4_i1.c
index 91138e1329d5..1a1a7109186c 100644
--- a/libgfortran/generated/cshift1_4_i1.c
+++ b/libgfortran/generated/cshift1_4_i1.c
@@ -35,20 +35,20 @@ cshift1_4_i1 (gfc_array_i1 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_1 *rptr;
   GFC_INTEGER_1 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_1 *sptr;
   const GFC_INTEGER_1 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_i1 (gfc_array_i1 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_i1 (gfc_array_i1 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_1*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_1) && roffset == sizeof (GFC_INTEGER_1))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_1);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_1);
@@ -147,21 +137,21 @@ cshift1_4_i1 (gfc_array_i1 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_1*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_1*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_1*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_1*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_i1 (gfc_array_i1 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_1*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_1*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_i1 (gfc_array_i1 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_1*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_1*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_i16.c b/libgfortran/generated/cshift1_4_i16.c
index 8efbb011ce9b..04c7fd627186 100644
--- a/libgfortran/generated/cshift1_4_i16.c
+++ b/libgfortran/generated/cshift1_4_i16.c
@@ -35,20 +35,20 @@ cshift1_4_i16 (gfc_array_i16 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_16 *rptr;
   GFC_INTEGER_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_16 *sptr;
   const GFC_INTEGER_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_i16 (gfc_array_i16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_i16 (gfc_array_i16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_16) && roffset == sizeof (GFC_INTEGER_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_16);
@@ -147,21 +137,21 @@ cshift1_4_i16 (gfc_array_i16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_16*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_16*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_i16 (gfc_array_i16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_i16 (gfc_array_i16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_i2.c b/libgfortran/generated/cshift1_4_i2.c
index 58c064b39532..84f7d5bf9112 100644
--- a/libgfortran/generated/cshift1_4_i2.c
+++ b/libgfortran/generated/cshift1_4_i2.c
@@ -35,20 +35,20 @@ cshift1_4_i2 (gfc_array_i2 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_2 *rptr;
   GFC_INTEGER_2 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_2 *sptr;
   const GFC_INTEGER_2 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_i2 (gfc_array_i2 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_i2 (gfc_array_i2 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_2*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_2) && roffset == sizeof (GFC_INTEGER_2))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_2);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_2);
@@ -147,21 +137,21 @@ cshift1_4_i2 (gfc_array_i2 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_2*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_2*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_2*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_2*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_i2 (gfc_array_i2 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_2*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_2*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_i2 (gfc_array_i2 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_2*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_2*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_i4.c b/libgfortran/generated/cshift1_4_i4.c
index d35530b52fa6..ca60649a5ae0 100644
--- a/libgfortran/generated/cshift1_4_i4.c
+++ b/libgfortran/generated/cshift1_4_i4.c
@@ -35,20 +35,20 @@ cshift1_4_i4 (gfc_array_i4 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_4 *rptr;
   GFC_INTEGER_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_4 *sptr;
   const GFC_INTEGER_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_i4 (gfc_array_i4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_i4 (gfc_array_i4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_4) && roffset == sizeof (GFC_INTEGER_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_4);
@@ -147,21 +137,21 @@ cshift1_4_i4 (gfc_array_i4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_4*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_4*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_i4 (gfc_array_i4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_i4 (gfc_array_i4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_i8.c b/libgfortran/generated/cshift1_4_i8.c
index ecd003848ee0..402d9aefde53 100644
--- a/libgfortran/generated/cshift1_4_i8.c
+++ b/libgfortran/generated/cshift1_4_i8.c
@@ -35,20 +35,20 @@ cshift1_4_i8 (gfc_array_i8 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_8 *rptr;
   GFC_INTEGER_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_8 *sptr;
   const GFC_INTEGER_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_i8 (gfc_array_i8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_i8 (gfc_array_i8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_8) && roffset == sizeof (GFC_INTEGER_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_8);
@@ -147,21 +137,21 @@ cshift1_4_i8 (gfc_array_i8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_8*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_8*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_i8 (gfc_array_i8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_i8 (gfc_array_i8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_r10.c b/libgfortran/generated/cshift1_4_r10.c
index 4cb9e6dc8493..fa41cbd509a5 100644
--- a/libgfortran/generated/cshift1_4_r10.c
+++ b/libgfortran/generated/cshift1_4_r10.c
@@ -35,20 +35,20 @@ cshift1_4_r10 (gfc_array_r10 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_10 *rptr;
   GFC_REAL_10 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_10 *sptr;
   const GFC_REAL_10 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_r10 (gfc_array_r10 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_r10 (gfc_array_r10 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_10*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_10) && roffset == sizeof (GFC_REAL_10))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_10);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_10);
@@ -147,21 +137,21 @@ cshift1_4_r10 (gfc_array_r10 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_10*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_10*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_10*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_10*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_r10 (gfc_array_r10 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_10*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_10*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_r10 (gfc_array_r10 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_10*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_10*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_r16.c b/libgfortran/generated/cshift1_4_r16.c
index 1784426fcd78..abae1e452fde 100644
--- a/libgfortran/generated/cshift1_4_r16.c
+++ b/libgfortran/generated/cshift1_4_r16.c
@@ -35,20 +35,20 @@ cshift1_4_r16 (gfc_array_r16 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_16 *rptr;
   GFC_REAL_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_16 *sptr;
   const GFC_REAL_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_r16 (gfc_array_r16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_r16 (gfc_array_r16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_16) && roffset == sizeof (GFC_REAL_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_16);
@@ -147,21 +137,21 @@ cshift1_4_r16 (gfc_array_r16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_16*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_16*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_r16 (gfc_array_r16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_r16 (gfc_array_r16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_r17.c b/libgfortran/generated/cshift1_4_r17.c
index 32a0f507c1ff..53ac111b191d 100644
--- a/libgfortran/generated/cshift1_4_r17.c
+++ b/libgfortran/generated/cshift1_4_r17.c
@@ -35,20 +35,20 @@ cshift1_4_r17 (gfc_array_r17 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_17 *rptr;
   GFC_REAL_17 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_17 *sptr;
   const GFC_REAL_17 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_r17 (gfc_array_r17 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_r17 (gfc_array_r17 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_17*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_17) && roffset == sizeof (GFC_REAL_17))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_17);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_17);
@@ -147,21 +137,21 @@ cshift1_4_r17 (gfc_array_r17 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_17*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_17*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_17*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_17*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_r17 (gfc_array_r17 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_17*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_17*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_r17 (gfc_array_r17 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_17*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_17*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_r4.c b/libgfortran/generated/cshift1_4_r4.c
index 4b4db20d99ae..db3b55af5d32 100644
--- a/libgfortran/generated/cshift1_4_r4.c
+++ b/libgfortran/generated/cshift1_4_r4.c
@@ -35,20 +35,20 @@ cshift1_4_r4 (gfc_array_r4 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_4 *rptr;
   GFC_REAL_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_4 *sptr;
   const GFC_REAL_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_r4 (gfc_array_r4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_r4 (gfc_array_r4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_4) && roffset == sizeof (GFC_REAL_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_4);
@@ -147,21 +137,21 @@ cshift1_4_r4 (gfc_array_r4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_4*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_4*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_r4 (gfc_array_r4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_r4 (gfc_array_r4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_4_r8.c b/libgfortran/generated/cshift1_4_r8.c
index cf76568b9383..79d7bb0705c0 100644
--- a/libgfortran/generated/cshift1_4_r8.c
+++ b/libgfortran/generated/cshift1_4_r8.c
@@ -35,20 +35,20 @@ cshift1_4_r8 (gfc_array_r8 * const restrict ret,
 		const GFC_INTEGER_4 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_8 *rptr;
   GFC_REAL_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_8 *sptr;
   const GFC_REAL_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_4_r8 (gfc_array_r8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_4_r8 (gfc_array_r8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_8) && roffset == sizeof (GFC_REAL_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_8);
@@ -147,21 +137,21 @@ cshift1_4_r8 (gfc_array_r8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_8*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_8*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_4_r8 (gfc_array_r8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_4*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_4_r8 (gfc_array_r8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_4*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8.c b/libgfortran/generated/cshift1_8.c
index d94f42d3989e..ec49b93be802 100644
--- a/libgfortran/generated/cshift1_8.c
+++ b/libgfortran/generated/cshift1_8.c
@@ -36,20 +36,20 @@ cshift1 (gfc_array_char * const restrict ret,
 	const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -87,12 +87,12 @@ cshift1 (gfc_array_char * const restrict ret,
           ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = sizeof (GFC_INTEGER_8);
           else
 	    str = GFC_DESCRIPTOR_EXTENT(ret,i-1) *
-	      GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
         }
     }
   else if (unlikely (compile_options.bounds_check))
@@ -214,36 +214,26 @@ cshift1 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -289,9 +279,9 @@ cshift1 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (GFC_INTEGER_8*) (((char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -301,9 +291,9 @@ cshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (GFC_INTEGER_8*) (((char*)hptr) - hspacing[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -314,9 +304,9 @@ cshift1 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (GFC_INTEGER_8*) (((char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_c10.c b/libgfortran/generated/cshift1_8_c10.c
index c78fbec090dd..127c0aeb4b58 100644
--- a/libgfortran/generated/cshift1_8_c10.c
+++ b/libgfortran/generated/cshift1_8_c10.c
@@ -35,20 +35,20 @@ cshift1_8_c10 (gfc_array_c10 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_10 *rptr;
   GFC_COMPLEX_10 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_10 *sptr;
   const GFC_COMPLEX_10 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_c10 (gfc_array_c10 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_c10 (gfc_array_c10 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_10*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_10) && roffset == sizeof (GFC_COMPLEX_10))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_10);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_10);
@@ -147,21 +137,21 @@ cshift1_8_c10 (gfc_array_c10 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_10*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_10*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_c10 (gfc_array_c10 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_10*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_c10 (gfc_array_c10 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_10*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_10*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_c16.c b/libgfortran/generated/cshift1_8_c16.c
index cea2c658178d..2a3aa8baddbf 100644
--- a/libgfortran/generated/cshift1_8_c16.c
+++ b/libgfortran/generated/cshift1_8_c16.c
@@ -35,20 +35,20 @@ cshift1_8_c16 (gfc_array_c16 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_16 *rptr;
   GFC_COMPLEX_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_16 *sptr;
   const GFC_COMPLEX_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_c16 (gfc_array_c16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_c16 (gfc_array_c16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_16) && roffset == sizeof (GFC_COMPLEX_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_16);
@@ -147,21 +137,21 @@ cshift1_8_c16 (gfc_array_c16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_16*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_16*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_c16 (gfc_array_c16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_c16 (gfc_array_c16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_c17.c b/libgfortran/generated/cshift1_8_c17.c
index bc4da3ab473d..cdef2b54079b 100644
--- a/libgfortran/generated/cshift1_8_c17.c
+++ b/libgfortran/generated/cshift1_8_c17.c
@@ -35,20 +35,20 @@ cshift1_8_c17 (gfc_array_c17 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_17 *rptr;
   GFC_COMPLEX_17 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_17 *sptr;
   const GFC_COMPLEX_17 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_c17 (gfc_array_c17 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_c17 (gfc_array_c17 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_17*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_17) && roffset == sizeof (GFC_COMPLEX_17))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_17);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_17);
@@ -147,21 +137,21 @@ cshift1_8_c17 (gfc_array_c17 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_17*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_17*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_c17 (gfc_array_c17 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_17*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_c17 (gfc_array_c17 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_17*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_17*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_c4.c b/libgfortran/generated/cshift1_8_c4.c
index 179562e2f060..3a1e9068f8da 100644
--- a/libgfortran/generated/cshift1_8_c4.c
+++ b/libgfortran/generated/cshift1_8_c4.c
@@ -35,20 +35,20 @@ cshift1_8_c4 (gfc_array_c4 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_4 *rptr;
   GFC_COMPLEX_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_4 *sptr;
   const GFC_COMPLEX_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_c4 (gfc_array_c4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_c4 (gfc_array_c4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_4) && roffset == sizeof (GFC_COMPLEX_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_4);
@@ -147,21 +137,21 @@ cshift1_8_c4 (gfc_array_c4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_4*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_4*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_c4 (gfc_array_c4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_c4 (gfc_array_c4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_c8.c b/libgfortran/generated/cshift1_8_c8.c
index 66e4cb7301d6..5606a8f8955c 100644
--- a/libgfortran/generated/cshift1_8_c8.c
+++ b/libgfortran/generated/cshift1_8_c8.c
@@ -35,20 +35,20 @@ cshift1_8_c8 (gfc_array_c8 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_COMPLEX_8 *rptr;
   GFC_COMPLEX_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_COMPLEX_8 *sptr;
   const GFC_COMPLEX_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_c8 (gfc_array_c8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_c8 (gfc_array_c8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_COMPLEX_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_COMPLEX_8) && roffset == sizeof (GFC_COMPLEX_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_COMPLEX_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_COMPLEX_8);
@@ -147,21 +137,21 @@ cshift1_8_c8 (gfc_array_c8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_8*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_COMPLEX_8*) (((char*)dest) + roffset);
+	      src = (GFC_COMPLEX_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_c8 (gfc_array_c8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_COMPLEX_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_c8 (gfc_array_c8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_COMPLEX_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_COMPLEX_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_i1.c b/libgfortran/generated/cshift1_8_i1.c
index d27abbfacf9f..2fe05f69ac1f 100644
--- a/libgfortran/generated/cshift1_8_i1.c
+++ b/libgfortran/generated/cshift1_8_i1.c
@@ -35,20 +35,20 @@ cshift1_8_i1 (gfc_array_i1 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_1 *rptr;
   GFC_INTEGER_1 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_1 *sptr;
   const GFC_INTEGER_1 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_i1 (gfc_array_i1 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_i1 (gfc_array_i1 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_1*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_1) && roffset == sizeof (GFC_INTEGER_1))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_1);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_1);
@@ -147,21 +137,21 @@ cshift1_8_i1 (gfc_array_i1 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_1*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_1*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_1*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_1*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_1*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_i1 (gfc_array_i1 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_1*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_1*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_i1 (gfc_array_i1 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_1*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_1*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_i16.c b/libgfortran/generated/cshift1_8_i16.c
index eef8d0eef952..a1552bdbe270 100644
--- a/libgfortran/generated/cshift1_8_i16.c
+++ b/libgfortran/generated/cshift1_8_i16.c
@@ -35,20 +35,20 @@ cshift1_8_i16 (gfc_array_i16 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_16 *rptr;
   GFC_INTEGER_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_16 *sptr;
   const GFC_INTEGER_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_i16 (gfc_array_i16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_i16 (gfc_array_i16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_16) && roffset == sizeof (GFC_INTEGER_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_16);
@@ -147,21 +137,21 @@ cshift1_8_i16 (gfc_array_i16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_16*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_16*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_i16 (gfc_array_i16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_i16 (gfc_array_i16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_i2.c b/libgfortran/generated/cshift1_8_i2.c
index bf6433295b8f..d57f193aa376 100644
--- a/libgfortran/generated/cshift1_8_i2.c
+++ b/libgfortran/generated/cshift1_8_i2.c
@@ -35,20 +35,20 @@ cshift1_8_i2 (gfc_array_i2 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_2 *rptr;
   GFC_INTEGER_2 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_2 *sptr;
   const GFC_INTEGER_2 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_i2 (gfc_array_i2 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_i2 (gfc_array_i2 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_2*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_2) && roffset == sizeof (GFC_INTEGER_2))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_2);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_2);
@@ -147,21 +137,21 @@ cshift1_8_i2 (gfc_array_i2 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_2*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_2*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_2*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_2*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_2*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_i2 (gfc_array_i2 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_2*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_2*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_i2 (gfc_array_i2 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_2*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_2*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_i4.c b/libgfortran/generated/cshift1_8_i4.c
index 6cdf0dbd4b63..c7107fd14021 100644
--- a/libgfortran/generated/cshift1_8_i4.c
+++ b/libgfortran/generated/cshift1_8_i4.c
@@ -35,20 +35,20 @@ cshift1_8_i4 (gfc_array_i4 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_4 *rptr;
   GFC_INTEGER_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_4 *sptr;
   const GFC_INTEGER_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_i4 (gfc_array_i4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_i4 (gfc_array_i4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_4) && roffset == sizeof (GFC_INTEGER_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_4);
@@ -147,21 +137,21 @@ cshift1_8_i4 (gfc_array_i4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_4*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_4*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_i4 (gfc_array_i4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_i4 (gfc_array_i4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_i8.c b/libgfortran/generated/cshift1_8_i8.c
index ae2013b8e9e4..195ba4a174a8 100644
--- a/libgfortran/generated/cshift1_8_i8.c
+++ b/libgfortran/generated/cshift1_8_i8.c
@@ -35,20 +35,20 @@ cshift1_8_i8 (gfc_array_i8 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_INTEGER_8 *rptr;
   GFC_INTEGER_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_INTEGER_8 *sptr;
   const GFC_INTEGER_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_i8 (gfc_array_i8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_i8 (gfc_array_i8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_INTEGER_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_INTEGER_8) && roffset == sizeof (GFC_INTEGER_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_INTEGER_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_INTEGER_8);
@@ -147,21 +137,21 @@ cshift1_8_i8 (gfc_array_i8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_8*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_INTEGER_8*) (((char*)dest) + roffset);
+	      src = (GFC_INTEGER_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_INTEGER_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_INTEGER_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_i8 (gfc_array_i8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_INTEGER_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_INTEGER_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_i8 (gfc_array_i8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_INTEGER_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_INTEGER_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_r10.c b/libgfortran/generated/cshift1_8_r10.c
index 9b422f2d4752..b1d5cec480e0 100644
--- a/libgfortran/generated/cshift1_8_r10.c
+++ b/libgfortran/generated/cshift1_8_r10.c
@@ -35,20 +35,20 @@ cshift1_8_r10 (gfc_array_r10 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_10 *rptr;
   GFC_REAL_10 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_10 *sptr;
   const GFC_REAL_10 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_r10 (gfc_array_r10 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_r10 (gfc_array_r10 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_10*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_10) && roffset == sizeof (GFC_REAL_10))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_10);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_10);
@@ -147,21 +137,21 @@ cshift1_8_r10 (gfc_array_r10 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_10*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_10*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_10*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_10*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_10*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_r10 (gfc_array_r10 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_10*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_10*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_r10 (gfc_array_r10 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_10*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_10*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_r16.c b/libgfortran/generated/cshift1_8_r16.c
index 6b0d0a396eb1..7db7a5e38ab5 100644
--- a/libgfortran/generated/cshift1_8_r16.c
+++ b/libgfortran/generated/cshift1_8_r16.c
@@ -35,20 +35,20 @@ cshift1_8_r16 (gfc_array_r16 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_16 *rptr;
   GFC_REAL_16 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_16 *sptr;
   const GFC_REAL_16 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_r16 (gfc_array_r16 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_r16 (gfc_array_r16 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_16*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_16) && roffset == sizeof (GFC_REAL_16))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_16);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_16);
@@ -147,21 +137,21 @@ cshift1_8_r16 (gfc_array_r16 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_16*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_16*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_16*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_16*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_16*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_r16 (gfc_array_r16 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_16*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_16*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_r16 (gfc_array_r16 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_16*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_16*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_r17.c b/libgfortran/generated/cshift1_8_r17.c
index 4e01328b0b0c..2abaf4bf0461 100644
--- a/libgfortran/generated/cshift1_8_r17.c
+++ b/libgfortran/generated/cshift1_8_r17.c
@@ -35,20 +35,20 @@ cshift1_8_r17 (gfc_array_r17 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_17 *rptr;
   GFC_REAL_17 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_17 *sptr;
   const GFC_REAL_17 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_r17 (gfc_array_r17 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_r17 (gfc_array_r17 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_17*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_17) && roffset == sizeof (GFC_REAL_17))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_17);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_17);
@@ -147,21 +137,21 @@ cshift1_8_r17 (gfc_array_r17 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_17*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_17*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_17*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_17*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_17*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_r17 (gfc_array_r17 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_17*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_17*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_r17 (gfc_array_r17 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_17*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_17*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_r4.c b/libgfortran/generated/cshift1_8_r4.c
index 97b78b45ce06..d864b9a48743 100644
--- a/libgfortran/generated/cshift1_8_r4.c
+++ b/libgfortran/generated/cshift1_8_r4.c
@@ -35,20 +35,20 @@ cshift1_8_r4 (gfc_array_r4 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_4 *rptr;
   GFC_REAL_4 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_4 *sptr;
   const GFC_REAL_4 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_r4 (gfc_array_r4 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_r4 (gfc_array_r4 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_4*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_4) && roffset == sizeof (GFC_REAL_4))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_4);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_4);
@@ -147,21 +137,21 @@ cshift1_8_r4 (gfc_array_r4 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_4*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_4*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_4*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_4*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_4*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_r4 (gfc_array_r4 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_4*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_4*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_r4 (gfc_array_r4 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_4*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_4*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/cshift1_8_r8.c b/libgfortran/generated/cshift1_8_r8.c
index 055acb3d757d..05dd0babf0d3 100644
--- a/libgfortran/generated/cshift1_8_r8.c
+++ b/libgfortran/generated/cshift1_8_r8.c
@@ -35,20 +35,20 @@ cshift1_8_r8 (gfc_array_r8 * const restrict ret,
 		const GFC_INTEGER_8 * const restrict pwhich)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   GFC_REAL_8 *rptr;
   GFC_REAL_8 *dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const GFC_REAL_8 *sptr;
   const GFC_REAL_8 *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -75,46 +75,36 @@ cshift1_8_r8 (gfc_array_r8 * const restrict ret,
   n = 0;
 
   /* Initialized for avoiding compiler warnings.  */
-  roffset = 1;
-  soffset = 1;
+  roffset = 0;
+  soffset = 0;
   len = 0;
 
   for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          if (roffset == 0)
-            roffset = 1;
-          soffset = GFC_DESCRIPTOR_STRIDE(array,dim);
-          if (soffset == 0)
-            soffset = 1;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE(array,dim);
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
-	  rs_ex[n] = rstride[n] * extent[n];
-	  ss_ex[n] = sstride[n] * extent[n];
-	  hs_ex[n] = hstride[n] * extent[n];
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
+	  rs_ex[n] = rspacing[n] * extent[n];
+	  ss_ex[n] = sspacing[n] * extent[n];
+	  hs_ex[n] = hspacing[n] * extent[n];
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = 1;
-  if (rstride[0] == 0)
-    rstride[0] = 1;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -133,9 +123,9 @@ cshift1_8_r8 (gfc_array_r8 * const restrict ret,
 	  if (sh < 0)
             sh += len;
 	}
-      src = &sptr[sh * soffset];
+      src = (const GFC_REAL_8*) (((char*)sptr) + sh * soffset);
       dest = rptr;
-      if (soffset == 1 && roffset == 1)
+      if (soffset == sizeof (GFC_REAL_8) && roffset == sizeof (GFC_REAL_8))
 	{
 	  size_t len1 = sh * sizeof (GFC_REAL_8);
 	  size_t len2 = (len - sh) * sizeof (GFC_REAL_8);
@@ -147,21 +137,21 @@ cshift1_8_r8 (gfc_array_r8 * const restrict ret,
 	  for (n = 0; n < len - sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_8*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	  for (src = sptr, n = 0; n < sh; n++)
 	    {
 	      *dest = *src;
-	      dest += roffset;
-	      src += soffset;
+	      dest = (GFC_REAL_8*) (((char*)dest) + roffset);
+	      src = (GFC_REAL_8*) (((char*)src) + soffset);
 	    }
 	}
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr = (GFC_REAL_8*) (((char*)rptr) + rspacing0);
+      sptr = (const GFC_REAL_8*) (((const char*)sptr) + sspacing0);
+      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -169,9 +159,9 @@ cshift1_8_r8 (gfc_array_r8 * const restrict ret,
           /* When we get to the end of a dimension, reset it and increment
              the next dimension.  */
           count[n] = 0;
-          rptr -= rs_ex[n];
-          sptr -= ss_ex[n];
-	  hptr -= hs_ex[n];
+          rptr = (GFC_REAL_8*) (((char*)rptr) - rs_ex[n]);
+          sptr = (const GFC_REAL_8*) (((const char*)sptr) - ss_ex[n]);
+	  hptr = (const GFC_INTEGER_8*) (((const char*)hptr) - hs_ex[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -182,9 +172,9 @@ cshift1_8_r8 (gfc_array_r8 * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr = (GFC_REAL_8*) (((char*)rptr) + rspacing[n]);
+              sptr = (const GFC_REAL_8*) (((const char*)sptr) + sspacing[n]);
+	      hptr = (const GFC_INTEGER_8*) (((const char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/eoshift1_16.c b/libgfortran/generated/eoshift1_16.c
index b78cd6feb355..7854bd6f8808 100644
--- a/libgfortran/generated/eoshift1_16.c
+++ b/libgfortran/generated/eoshift1_16.c
@@ -38,20 +38,20 @@ eoshift1 (gfc_array_char * const restrict ret,
 	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char * restrict dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -93,12 +93,12 @@ eoshift1 (gfc_array_char * const restrict ret,
 	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = size;
           else
             str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
-	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      * GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
 
         }
       /* xmallocarray allocates a single byte for zero size.  */
@@ -125,36 +125,26 @@ eoshift1 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -223,9 +213,9 @@ eoshift1 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (const GFC_INTEGER_16*) (((char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -235,9 +225,9 @@ eoshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (const GFC_INTEGER_16*) (((char*)hptr) - hspacing[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -248,9 +238,9 @@ eoshift1 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (const GFC_INTEGER_16*) (((char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/eoshift1_4.c b/libgfortran/generated/eoshift1_4.c
index e013da8dc223..70d8e414498d 100644
--- a/libgfortran/generated/eoshift1_4.c
+++ b/libgfortran/generated/eoshift1_4.c
@@ -38,20 +38,20 @@ eoshift1 (gfc_array_char * const restrict ret,
 	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char * restrict dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -93,12 +93,12 @@ eoshift1 (gfc_array_char * const restrict ret,
 	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = size;
           else
             str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
-	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      * GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
 
         }
       /* xmallocarray allocates a single byte for zero size.  */
@@ -125,36 +125,26 @@ eoshift1 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -223,9 +213,9 @@ eoshift1 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (const GFC_INTEGER_4*) (((char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -235,9 +225,9 @@ eoshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (const GFC_INTEGER_4*) (((char*)hptr) - hspacing[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -248,9 +238,9 @@ eoshift1 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (const GFC_INTEGER_4*) (((char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/eoshift1_8.c b/libgfortran/generated/eoshift1_8.c
index 061ce0879cf4..8d2ea7803282 100644
--- a/libgfortran/generated/eoshift1_8.c
+++ b/libgfortran/generated/eoshift1_8.c
@@ -38,20 +38,20 @@ eoshift1 (gfc_array_char * const restrict ret,
 	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char * restrict dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -93,12 +93,12 @@ eoshift1 (gfc_array_char * const restrict ret,
 	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = size;
           else
             str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
-	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      * GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
 
         }
       /* xmallocarray allocates a single byte for zero size.  */
@@ -125,36 +125,26 @@ eoshift1 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -223,9 +213,9 @@ eoshift1 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (const GFC_INTEGER_8*) (((char*)hptr) + hspacing0);
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -235,9 +225,9 @@ eoshift1 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (const GFC_INTEGER_8*) (((char*)hptr) - hspacing[n] * extent[n]);
           n++;
           if (n >= dim - 1)
             {
@@ -248,9 +238,9 @@ eoshift1 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (const GFC_INTEGER_8*) (((char*)hptr) + hspacing[n]);
             }
         }
     }
diff --git a/libgfortran/generated/eoshift3_16.c b/libgfortran/generated/eoshift3_16.c
index 911dd1c863ca..a6bd34718a7b 100644
--- a/libgfortran/generated/eoshift3_16.c
+++ b/libgfortran/generated/eoshift3_16.c
@@ -38,24 +38,24 @@ eoshift3 (gfc_array_char * const restrict ret,
 	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char * restrict dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_16 *hptr;
   /* b.* indicates the bound array.  */
-  index_type bstride[GFC_MAX_DIMENSIONS];
-  index_type bstride0;
+  index_type bspacing[GFC_MAX_DIMENSIONS];
+  index_type bspacing0;
   const char *bptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -95,12 +95,12 @@ eoshift3 (gfc_array_char * const restrict ret,
 	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = size;
           else
             str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
-	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      * GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
 
         }
       /* xmallocarray allocates a single byte for zero size.  */
@@ -129,43 +129,31 @@ eoshift3 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           if (bound)
-            bstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(bound,n);
+            bspacing[n] = GFC_DESCRIPTOR_SPACING(bound,n);
           else
-            bstride[n] = 0;
+            bspacing[n] = 0;
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
-  if (bound && bstride[0] == 0)
-    bstride[0] = size;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
-  bstride0 = bstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
+  bspacing0 = bspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -239,10 +227,10 @@ eoshift3 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
-      bptr += bstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (const GFC_INTEGER_16*) (((char*)hptr) + hspacing0);
+      bptr += bspacing0;
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -252,10 +240,10 @@ eoshift3 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
-          bptr -= bstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (const GFC_INTEGER_16*) (((char*)hptr) - hspacing[n] * extent[n]);
+          bptr -= bspacing[n] * extent[n];
           n++;
           if (n >= dim - 1)
             {
@@ -266,10 +254,10 @@ eoshift3 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
-              bptr += bstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (const GFC_INTEGER_16*) (((char*)hptr) + hspacing[n]);
+              bptr += bspacing[n];
             }
         }
     }
diff --git a/libgfortran/generated/eoshift3_4.c b/libgfortran/generated/eoshift3_4.c
index e2a4deb40566..1b12b2aaa448 100644
--- a/libgfortran/generated/eoshift3_4.c
+++ b/libgfortran/generated/eoshift3_4.c
@@ -38,24 +38,24 @@ eoshift3 (gfc_array_char * const restrict ret,
 	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char * restrict dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_4 *hptr;
   /* b.* indicates the bound array.  */
-  index_type bstride[GFC_MAX_DIMENSIONS];
-  index_type bstride0;
+  index_type bspacing[GFC_MAX_DIMENSIONS];
+  index_type bspacing0;
   const char *bptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -95,12 +95,12 @@ eoshift3 (gfc_array_char * const restrict ret,
 	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = size;
           else
             str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
-	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      * GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
 
         }
       /* xmallocarray allocates a single byte for zero size.  */
@@ -129,43 +129,31 @@ eoshift3 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           if (bound)
-            bstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(bound,n);
+            bspacing[n] = GFC_DESCRIPTOR_SPACING(bound,n);
           else
-            bstride[n] = 0;
+            bspacing[n] = 0;
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
-  if (bound && bstride[0] == 0)
-    bstride[0] = size;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
-  bstride0 = bstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
+  bspacing0 = bspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -239,10 +227,10 @@ eoshift3 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
-      bptr += bstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (const GFC_INTEGER_4*) (((char*)hptr) + hspacing0);
+      bptr += bspacing0;
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -252,10 +240,10 @@ eoshift3 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
-          bptr -= bstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (const GFC_INTEGER_4*) (((char*)hptr) - hspacing[n] * extent[n]);
+          bptr -= bspacing[n] * extent[n];
           n++;
           if (n >= dim - 1)
             {
@@ -266,10 +254,10 @@ eoshift3 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
-              bptr += bstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (const GFC_INTEGER_4*) (((char*)hptr) + hspacing[n]);
+              bptr += bspacing[n];
             }
         }
     }
diff --git a/libgfortran/generated/eoshift3_8.c b/libgfortran/generated/eoshift3_8.c
index 5581a9192b15..cd0abee8161f 100644
--- a/libgfortran/generated/eoshift3_8.c
+++ b/libgfortran/generated/eoshift3_8.c
@@ -38,24 +38,24 @@ eoshift3 (gfc_array_char * const restrict ret,
 	const char * filler, index_type filler_len)
 {
   /* r.* indicates the return array.  */
-  index_type rstride[GFC_MAX_DIMENSIONS];
-  index_type rstride0;
+  index_type rspacing[GFC_MAX_DIMENSIONS];
+  index_type rspacing0;
   index_type roffset;
   char *rptr;
   char * restrict dest;
   /* s.* indicates the source array.  */
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type sstride0;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type sspacing0;
   index_type soffset;
   const char *sptr;
   const char *src;
   /* h.* indicates the shift array.  */
-  index_type hstride[GFC_MAX_DIMENSIONS];
-  index_type hstride0;
+  index_type hspacing[GFC_MAX_DIMENSIONS];
+  index_type hspacing0;
   const GFC_INTEGER_8 *hptr;
   /* b.* indicates the bound array.  */
-  index_type bstride[GFC_MAX_DIMENSIONS];
-  index_type bstride0;
+  index_type bspacing[GFC_MAX_DIMENSIONS];
+  index_type bspacing0;
   const char *bptr;
 
   index_type count[GFC_MAX_DIMENSIONS];
@@ -95,12 +95,12 @@ eoshift3 (gfc_array_char * const restrict ret,
 	  ub = GFC_DESCRIPTOR_EXTENT(array,i) - 1;
 
           if (i == 0)
-            str = 1;
+            str = size;
           else
             str = GFC_DESCRIPTOR_EXTENT(ret,i-1)
-	      * GFC_DESCRIPTOR_STRIDE(ret,i-1);
+	      * GFC_DESCRIPTOR_SPACING(ret,i-1);
 
-	  GFC_DIMENSION_SET(ret->dim[i], 0, ub, str);
+	  GFC_DESCRIPTOR_DIMENSION_SET(ret, i, 0, ub, str);
 
         }
       /* xmallocarray allocates a single byte for zero size.  */
@@ -129,43 +129,31 @@ eoshift3 (gfc_array_char * const restrict ret,
     {
       if (dim == which)
         {
-          roffset = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          if (roffset == 0)
-            roffset = size;
-          soffset = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
-          if (soffset == 0)
-            soffset = size;
+          roffset = GFC_DESCRIPTOR_SPACING(ret,dim);
+          soffset = GFC_DESCRIPTOR_SPACING(array,dim);
           len = GFC_DESCRIPTOR_EXTENT(array,dim);
         }
       else
         {
           count[n] = 0;
           extent[n] = GFC_DESCRIPTOR_EXTENT(array,dim);
-          rstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(ret,dim);
-          sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
+          rspacing[n] = GFC_DESCRIPTOR_SPACING(ret,dim);
+          sspacing[n] = GFC_DESCRIPTOR_SPACING(array,dim);
 
-          hstride[n] = GFC_DESCRIPTOR_STRIDE(h,n);
+          hspacing[n] = GFC_DESCRIPTOR_SPACING(h,n);
           if (bound)
-            bstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(bound,n);
+            bspacing[n] = GFC_DESCRIPTOR_SPACING(bound,n);
           else
-            bstride[n] = 0;
+            bspacing[n] = 0;
           n++;
         }
     }
-  if (sstride[0] == 0)
-    sstride[0] = size;
-  if (rstride[0] == 0)
-    rstride[0] = size;
-  if (hstride[0] == 0)
-    hstride[0] = 1;
-  if (bound && bstride[0] == 0)
-    bstride[0] = size;
 
   dim = GFC_DESCRIPTOR_RANK (array);
-  rstride0 = rstride[0];
-  sstride0 = sstride[0];
-  hstride0 = hstride[0];
-  bstride0 = bstride[0];
+  rspacing0 = rspacing[0];
+  sspacing0 = sspacing[0];
+  hspacing0 = hspacing[0];
+  bspacing0 = bspacing[0];
   rptr = ret->base_addr;
   sptr = array->base_addr;
   hptr = h->base_addr;
@@ -239,10 +227,10 @@ eoshift3 (gfc_array_char * const restrict ret,
 	  }
 
       /* Advance to the next section.  */
-      rptr += rstride0;
-      sptr += sstride0;
-      hptr += hstride0;
-      bptr += bstride0;
+      rptr += rspacing0;
+      sptr += sspacing0;
+      hptr = (const GFC_INTEGER_8*) (((char*)hptr) + hspacing0);
+      bptr += bspacing0;
       count[0]++;
       n = 0;
       while (count[n] == extent[n])
@@ -252,10 +240,10 @@ eoshift3 (gfc_array_char * const restrict ret,
           count[n] = 0;
           /* We could precalculate these products, but this is a less
              frequently used path so probably not worth it.  */
-          rptr -= rstride[n] * extent[n];
-          sptr -= sstride[n] * extent[n];
-	  hptr -= hstride[n] * extent[n];
-          bptr -= bstride[n] * extent[n];
+          rptr -= rspacing[n] * extent[n];
+          sptr -= sspacing[n] * extent[n];
+	  hptr = (const GFC_INTEGER_8*) (((char*)hptr) - hspacing[n] * extent[n]);
+          bptr -= bspacing[n] * extent[n];
           n++;
           if (n >= dim - 1)
             {
@@ -266,10 +254,10 @@ eoshift3 (gfc_array_char * const restrict ret,
           else
             {
               count[n]++;
-              rptr += rstride[n];
-              sptr += sstride[n];
-	      hptr += hstride[n];
-              bptr += bstride[n];
+              rptr += rspacing[n];
+              sptr += sspacing[n];
+	      hptr = (const GFC_INTEGER_8*) (((char*)hptr) + hspacing[n]);
+              bptr += bspacing[n];
             }
         }
     }
diff --git a/libgfortran/generated/findloc0_c10.c b/libgfortran/generated/findloc0_c10.c
index 2ddbc45e898e..ee8a08e225cf 100644
--- a/libgfortran/generated/findloc0_c10.c
+++ b/libgfortran/generated/findloc0_c10.c
@@ -40,13 +40,10 @@ findloc0_c10 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_10 *base;
-  index_type * restrict dest;
   index_type rank;
   index_type n;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -54,7 +51,7 @@ findloc0_c10 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -66,29 +63,26 @@ findloc0_c10 (gfc_array_index_type * const restrict retarray,
 				"FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	base = (GFC_COMPLEX_10*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
 
       while (1)
         {
@@ -97,11 +91,11 @@ findloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
+	      base = (GFC_COMPLEX_10*) (((char*)base) - sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -112,14 +106,14 @@ findloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_10*) (((char*)base) + sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
+		  base = (GFC_COMPLEX_10*) (((char*)base) - sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -134,11 +128,11 @@ findloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
+	      base = (GFC_COMPLEX_10*) (((char*)base) + sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -149,14 +143,14 @@ findloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_10*) (((char*)base) - sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n] * 1;
+		  base = (GFC_COMPLEX_10*) (((char*)base) + sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -176,16 +170,13 @@ mfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type mstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type mspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_10 *base;
-  index_type * restrict dest;
   GFC_LOGICAL_1 *mbase;
   index_type rank;
   index_type n;
   int mask_kind;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -193,7 +184,7 @@ mfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -222,31 +213,31 @@ mfindloc0_c10 (gfc_array_index_type * const restrict retarray,
   else
     internal_error (NULL, "Funny sized logical array");
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
-      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
+      mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
-      mbase = mbase + (sz - 1) * mask_kind;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	{
+	  base = (GFC_COMPLEX_10*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
+	  mbase = mbase + (extent[n] - 1) * mspacing[n];
+	}
+
       while (1)
         {
 	  do
@@ -254,12 +245,12 @@ mfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
-	      mbase -= mstride[0];
+	      base = (GFC_COMPLEX_10*) (((char*)base) - sspacing[0]);
+	      mbase -= mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -270,16 +261,16 @@ mfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_10*) (((char*)base) + sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_10*) (((char*)base) - sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -294,12 +285,12 @@ mfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
-	      mbase += mstride[0];
+	      base = (GFC_COMPLEX_10*) (((char*)base) + sspacing[0]);
+	      mbase += mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -310,16 +301,16 @@ mfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_10*) (((char*)base) - sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n]* 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_10*) (((char*)base) + sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -338,8 +329,6 @@ sfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 	    GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back)
 {
   index_type rank;
-  index_type dstride;
-  index_type * restrict dest;
   index_type n;
 
   if (mask == NULL || *mask)
@@ -355,7 +344,7 @@ sfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -366,10 +355,8 @@ sfindloc0_c10 (gfc_array_index_type * const restrict retarray,
 			       "FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
   for (n = 0; n<rank; n++)
-    dest[n * dstride] = 0 ;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0 ;
 }
 
 #endif
diff --git a/libgfortran/generated/findloc0_c16.c b/libgfortran/generated/findloc0_c16.c
index a124091283f3..f9e07a127165 100644
--- a/libgfortran/generated/findloc0_c16.c
+++ b/libgfortran/generated/findloc0_c16.c
@@ -40,13 +40,10 @@ findloc0_c16 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_16 *base;
-  index_type * restrict dest;
   index_type rank;
   index_type n;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -54,7 +51,7 @@ findloc0_c16 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -66,29 +63,26 @@ findloc0_c16 (gfc_array_index_type * const restrict retarray,
 				"FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	base = (GFC_COMPLEX_16*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
 
       while (1)
         {
@@ -97,11 +91,11 @@ findloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
+	      base = (GFC_COMPLEX_16*) (((char*)base) - sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -112,14 +106,14 @@ findloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_16*) (((char*)base) + sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
+		  base = (GFC_COMPLEX_16*) (((char*)base) - sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -134,11 +128,11 @@ findloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
+	      base = (GFC_COMPLEX_16*) (((char*)base) + sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -149,14 +143,14 @@ findloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_16*) (((char*)base) - sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n] * 1;
+		  base = (GFC_COMPLEX_16*) (((char*)base) + sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -176,16 +170,13 @@ mfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type mstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type mspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_16 *base;
-  index_type * restrict dest;
   GFC_LOGICAL_1 *mbase;
   index_type rank;
   index_type n;
   int mask_kind;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -193,7 +184,7 @@ mfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -222,31 +213,31 @@ mfindloc0_c16 (gfc_array_index_type * const restrict retarray,
   else
     internal_error (NULL, "Funny sized logical array");
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
-      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
+      mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
-      mbase = mbase + (sz - 1) * mask_kind;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	{
+	  base = (GFC_COMPLEX_16*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
+	  mbase = mbase + (extent[n] - 1) * mspacing[n];
+	}
+
       while (1)
         {
 	  do
@@ -254,12 +245,12 @@ mfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
-	      mbase -= mstride[0];
+	      base = (GFC_COMPLEX_16*) (((char*)base) - sspacing[0]);
+	      mbase -= mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -270,16 +261,16 @@ mfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_16*) (((char*)base) + sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_16*) (((char*)base) - sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -294,12 +285,12 @@ mfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
-	      mbase += mstride[0];
+	      base = (GFC_COMPLEX_16*) (((char*)base) + sspacing[0]);
+	      mbase += mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -310,16 +301,16 @@ mfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_16*) (((char*)base) - sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n]* 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_16*) (((char*)base) + sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -338,8 +329,6 @@ sfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 	    GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back)
 {
   index_type rank;
-  index_type dstride;
-  index_type * restrict dest;
   index_type n;
 
   if (mask == NULL || *mask)
@@ -355,7 +344,7 @@ sfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -366,10 +355,8 @@ sfindloc0_c16 (gfc_array_index_type * const restrict retarray,
 			       "FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
   for (n = 0; n<rank; n++)
-    dest[n * dstride] = 0 ;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0 ;
 }
 
 #endif
diff --git a/libgfortran/generated/findloc0_c17.c b/libgfortran/generated/findloc0_c17.c
index a93a98e414a5..fa77f113b31e 100644
--- a/libgfortran/generated/findloc0_c17.c
+++ b/libgfortran/generated/findloc0_c17.c
@@ -40,13 +40,10 @@ findloc0_c17 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_17 *base;
-  index_type * restrict dest;
   index_type rank;
   index_type n;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -54,7 +51,7 @@ findloc0_c17 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -66,29 +63,26 @@ findloc0_c17 (gfc_array_index_type * const restrict retarray,
 				"FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	base = (GFC_COMPLEX_17*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
 
       while (1)
         {
@@ -97,11 +91,11 @@ findloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
+	      base = (GFC_COMPLEX_17*) (((char*)base) - sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -112,14 +106,14 @@ findloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_17*) (((char*)base) + sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
+		  base = (GFC_COMPLEX_17*) (((char*)base) - sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -134,11 +128,11 @@ findloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
+	      base = (GFC_COMPLEX_17*) (((char*)base) + sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -149,14 +143,14 @@ findloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_17*) (((char*)base) - sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n] * 1;
+		  base = (GFC_COMPLEX_17*) (((char*)base) + sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -176,16 +170,13 @@ mfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type mstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type mspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_17 *base;
-  index_type * restrict dest;
   GFC_LOGICAL_1 *mbase;
   index_type rank;
   index_type n;
   int mask_kind;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -193,7 +184,7 @@ mfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -222,31 +213,31 @@ mfindloc0_c17 (gfc_array_index_type * const restrict retarray,
   else
     internal_error (NULL, "Funny sized logical array");
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
-      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
+      mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
-      mbase = mbase + (sz - 1) * mask_kind;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	{
+	  base = (GFC_COMPLEX_17*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
+	  mbase = mbase + (extent[n] - 1) * mspacing[n];
+	}
+
       while (1)
         {
 	  do
@@ -254,12 +245,12 @@ mfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
-	      mbase -= mstride[0];
+	      base = (GFC_COMPLEX_17*) (((char*)base) - sspacing[0]);
+	      mbase -= mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -270,16 +261,16 @@ mfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_17*) (((char*)base) + sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_17*) (((char*)base) - sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -294,12 +285,12 @@ mfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
-	      mbase += mstride[0];
+	      base = (GFC_COMPLEX_17*) (((char*)base) + sspacing[0]);
+	      mbase += mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -310,16 +301,16 @@ mfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_17*) (((char*)base) - sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n]* 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_17*) (((char*)base) + sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -338,8 +329,6 @@ sfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 	    GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back)
 {
   index_type rank;
-  index_type dstride;
-  index_type * restrict dest;
   index_type n;
 
   if (mask == NULL || *mask)
@@ -355,7 +344,7 @@ sfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -366,10 +355,8 @@ sfindloc0_c17 (gfc_array_index_type * const restrict retarray,
 			       "FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
   for (n = 0; n<rank; n++)
-    dest[n * dstride] = 0 ;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0 ;
 }
 
 #endif
diff --git a/libgfortran/generated/findloc0_c4.c b/libgfortran/generated/findloc0_c4.c
index 04deab85ef7f..f9ac7062a185 100644
--- a/libgfortran/generated/findloc0_c4.c
+++ b/libgfortran/generated/findloc0_c4.c
@@ -40,13 +40,10 @@ findloc0_c4 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_4 *base;
-  index_type * restrict dest;
   index_type rank;
   index_type n;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -54,7 +51,7 @@ findloc0_c4 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -66,29 +63,26 @@ findloc0_c4 (gfc_array_index_type * const restrict retarray,
 				"FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	base = (GFC_COMPLEX_4*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
 
       while (1)
         {
@@ -97,11 +91,11 @@ findloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
+	      base = (GFC_COMPLEX_4*) (((char*)base) - sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -112,14 +106,14 @@ findloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_4*) (((char*)base) + sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
+		  base = (GFC_COMPLEX_4*) (((char*)base) - sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -134,11 +128,11 @@ findloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
+	      base = (GFC_COMPLEX_4*) (((char*)base) + sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -149,14 +143,14 @@ findloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_4*) (((char*)base) - sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n] * 1;
+		  base = (GFC_COMPLEX_4*) (((char*)base) + sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -176,16 +170,13 @@ mfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type mstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type mspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_4 *base;
-  index_type * restrict dest;
   GFC_LOGICAL_1 *mbase;
   index_type rank;
   index_type n;
   int mask_kind;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -193,7 +184,7 @@ mfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -222,31 +213,31 @@ mfindloc0_c4 (gfc_array_index_type * const restrict retarray,
   else
     internal_error (NULL, "Funny sized logical array");
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
-      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
+      mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
-      mbase = mbase + (sz - 1) * mask_kind;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	{
+	  base = (GFC_COMPLEX_4*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
+	  mbase = mbase + (extent[n] - 1) * mspacing[n];
+	}
+
       while (1)
         {
 	  do
@@ -254,12 +245,12 @@ mfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
-	      mbase -= mstride[0];
+	      base = (GFC_COMPLEX_4*) (((char*)base) - sspacing[0]);
+	      mbase -= mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -270,16 +261,16 @@ mfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_4*) (((char*)base) + sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_4*) (((char*)base) - sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -294,12 +285,12 @@ mfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
-	      mbase += mstride[0];
+	      base = (GFC_COMPLEX_4*) (((char*)base) + sspacing[0]);
+	      mbase += mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -310,16 +301,16 @@ mfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_4*) (((char*)base) - sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n]* 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_4*) (((char*)base) + sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -338,8 +329,6 @@ sfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 	    GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back)
 {
   index_type rank;
-  index_type dstride;
-  index_type * restrict dest;
   index_type n;
 
   if (mask == NULL || *mask)
@@ -355,7 +344,7 @@ sfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -366,10 +355,8 @@ sfindloc0_c4 (gfc_array_index_type * const restrict retarray,
 			       "FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
   for (n = 0; n<rank; n++)
-    dest[n * dstride] = 0 ;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0 ;
 }
 
 #endif
diff --git a/libgfortran/generated/findloc0_c8.c b/libgfortran/generated/findloc0_c8.c
index bb3d59acc540..2117c488e4b1 100644
--- a/libgfortran/generated/findloc0_c8.c
+++ b/libgfortran/generated/findloc0_c8.c
@@ -40,13 +40,10 @@ findloc0_c8 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_8 *base;
-  index_type * restrict dest;
   index_type rank;
   index_type n;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -54,7 +51,7 @@ findloc0_c8 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -66,29 +63,26 @@ findloc0_c8 (gfc_array_index_type * const restrict retarray,
 				"FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	base = (GFC_COMPLEX_8*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
 
       while (1)
         {
@@ -97,11 +91,11 @@ findloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
+	      base = (GFC_COMPLEX_8*) (((char*)base) - sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -112,14 +106,14 @@ findloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_8*) (((char*)base) + sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
+		  base = (GFC_COMPLEX_8*) (((char*)base) - sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -134,11 +128,11 @@ findloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
+	      base = (GFC_COMPLEX_8*) (((char*)base) + sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -149,14 +143,14 @@ findloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
+	      base = (GFC_COMPLEX_8*) (((char*)base) - sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n] * 1;
+		  base = (GFC_COMPLEX_8*) (((char*)base) + sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -176,16 +170,13 @@ mfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type mstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
+  index_type mspacing[GFC_MAX_DIMENSIONS];
   const GFC_COMPLEX_8 *base;
-  index_type * restrict dest;
   GFC_LOGICAL_1 *mbase;
   index_type rank;
   index_type n;
   int mask_kind;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -193,7 +184,7 @@ mfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -222,31 +213,31 @@ mfindloc0_c8 (gfc_array_index_type * const restrict retarray,
   else
     internal_error (NULL, "Funny sized logical array");
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
-      mstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(mask,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
+      mspacing[n] = GFC_DESCRIPTOR_SPACING(mask,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
-      mbase = mbase + (sz - 1) * mask_kind;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	{
+	  base = (GFC_COMPLEX_8*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
+	  mbase = mbase + (extent[n] - 1) * mspacing[n];
+	}
+
       while (1)
         {
 	  do
@@ -254,12 +245,12 @@ mfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
-	      mbase -= mstride[0];
+	      base = (GFC_COMPLEX_8*) (((char*)base) - sspacing[0]);
+	      mbase -= mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -270,16 +261,16 @@ mfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_8*) (((char*)base) + sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_8*) (((char*)base) - sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -294,12 +285,12 @@ mfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*mbase && *base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
-	      mbase += mstride[0];
+	      base = (GFC_COMPLEX_8*) (((char*)base) + sspacing[0]);
+	      mbase += mspacing[0];
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -310,16 +301,16 @@ mfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
-	      mbase -= mstride[n] * extent[n];
+	      base = (GFC_COMPLEX_8*) (((char*)base) - sspacing[n] * extent[n]);
+	      mbase -= mspacing[n] * extent[n];
 	      n++;
 	      if (n >= rank)
 		return;
 	      else
 		{
 		  count[n]++;
-		  base += sstride[n]* 1;
-		  mbase += mstride[n];
+		  base = (GFC_COMPLEX_8*) (((char*)base) + sspacing[n]);
+		  mbase += mspacing[n];
 		}
 	    } while (count[n] == extent[n]);
 	}
@@ -338,8 +329,6 @@ sfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 	    GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back)
 {
   index_type rank;
-  index_type dstride;
-  index_type * restrict dest;
   index_type n;
 
   if (mask == NULL || *mask)
@@ -355,7 +344,7 @@ sfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -366,10 +355,8 @@ sfindloc0_c8 (gfc_array_index_type * const restrict retarray,
 			       "FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
   for (n = 0; n<rank; n++)
-    dest[n * dstride] = 0 ;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0 ;
 }
 
 #endif
diff --git a/libgfortran/generated/findloc0_i1.c b/libgfortran/generated/findloc0_i1.c
index 4a6162107257..e9fc4368292e 100644
--- a/libgfortran/generated/findloc0_i1.c
+++ b/libgfortran/generated/findloc0_i1.c
@@ -40,13 +40,10 @@ findloc0_i1 (gfc_array_index_type * const restrict retarray,
 {
   index_type count[GFC_MAX_DIMENSIONS];
   index_type extent[GFC_MAX_DIMENSIONS];
-  index_type sstride[GFC_MAX_DIMENSIONS];
-  index_type dstride;
+  index_type sspacing[GFC_MAX_DIMENSIONS];
   const GFC_INTEGER_1 *base;
-  index_type * restrict dest;
   index_type rank;
   index_type n;
-  index_type sz;
 
   rank = GFC_DESCRIPTOR_RANK (array);
   if (rank <= 0)
@@ -54,7 +51,7 @@ findloc0_i1 (gfc_array_index_type * const restrict retarray,
 
   if (retarray->base_addr == NULL)
     {
-      GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
+      GFC_DESCRIPTOR_DIMENSION_SET(retarray, 0, 0, rank-1, sizeof (index_type));
       retarray->dtype.rank = 1;
       retarray->offset = 0;
       retarray->base_addr = xmallocarray (rank, sizeof (index_type));
@@ -66,29 +63,26 @@ findloc0_i1 (gfc_array_index_type * const restrict retarray,
 				"FINDLOC");
     }
 
-  dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
-  dest = retarray->base_addr;
-
   /* Set the return value.  */
   for (n = 0; n < rank; n++)
-    dest[n * dstride] = 0;
+    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = 0;
 
-  sz = 1;
   for (n = 0; n < rank; n++)
     {
-      sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
+      sspacing[n] = GFC_DESCRIPTOR_SPACING(array,n);
       extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
-      sz *= extent[n];
       if (extent[n] <= 0)
 	return;
     }
 
-    for (n = 0; n < rank; n++)
-      count[n] = 0;
+  for (n = 0; n < rank; n++)
+    count[n] = 0;
 
   if (back)
     {
-      base = array->base_addr + (sz - 1) * 1;
+      base = array->base_addr;
+      for (n = 0; n < rank; n++)
+	base = (GFC_INTEGER_1*) (((char*)base) + (extent[n] - 1) * sspacing[n]);
 
       while (1)
         {
@@ -97,11 +91,11 @@ findloc0_i1 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = extent[n] - count[n];
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = extent[n] - count[n];
 
 		  return;
 		}
-	      base -= sstride[0] * 1;
+	      base = (GFC_INTEGER_1*) (((char*)base) - sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -112,14 +106,14 @@ findloc0_i1 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base += sstride[n] * extent[n] * 1;
+	      base = (GFC_INTEGER_1*) (((char*)base) + sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{
 		  count[n]++;
-		  base -= sstride[n] * 1;
+		  base = (GFC_INTEGER_1*) (((char*)base) - sspacing[n]);
 		}
 	    } while (count[n] == extent[n]);      
 	}
@@ -134,11 +128,11 @@ findloc0_i1 (gfc_array_index_type * const restrict retarray,
 	      if (unlikely(*base == value))
 	        {
 		  for (n = 0; n < rank; n++)
-		    dest[n * dstride] = count[n] + 1;
+		    GFC_DESCRIPTOR1_ELEM (index_type, retarray, n) = count[n] + 1;
 
 		  return;
 		}
-	      base += sstride[0] * 1;
+	      base = (GFC_INTEGER_1*) (((char*)base) + sspacing[0]);
 	    } while(++count[0] != extent[0]);
 
 	  n = 0;
@@ -149,14 +143,14 @@ findloc0_i1 (gfc_array_index_type * const restrict retarray,
 	      count[n] = 0;
 	      /* We could precalculate these products, but this is a less
 		 frequently used path so probably not worth it.  */
-	      base -= sstride[n] * extent[n] * 1;
+	      base = (GFC_INTEGER_1*) (((char*)base) - sspacing[n] * extent[n]);
 	      n++;
 	      if (n >= rank)
 	        return;
 	      else
 		{[...]

[diff truncated at 524288 bytes]


More information about the Gcc-cvs mailing list