https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127092

            Bug ID: 127092
           Summary: [17 Regression] Ranger folds CEIL_DIV_EXPR and
                    ROUND_DIV_EXPR to zero for some nonnegative operands
                    that satisfy a < b
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---

Fortran reproducer:
program main
  implicit none
  if (transfer_count(3, 8) /= 1) error stop 1
contains
  integer function transfer_count(n, m)
    integer, intent(in) :: n, m
    character(len=n) :: source
    character(len=m) :: mold(1)
    if (len(source, kind=8) >= len(mold, kind=8)) then
      transfer_count = -1
      return
    end if
    source = ""
    mold = ""
    transfer_count = size(transfer(source, mold))
  end function
end program

e.g. on aarch64 aborts at -O2 and passes at -O0

Reply via email to