public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45425]  New: where mask not applied before where clause evaluated
@ 2010-08-27 10:03 aronaldg at gmail dot com
  2010-08-27 11:58 ` [Bug fortran/45425] Bounds check applied before MASK of WHERE construct burnus at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: aronaldg at gmail dot com @ 2010-08-27 10:03 UTC (permalink / raw)
  To: gcc-bugs

This is the system

uname -a
Linux argux9.fuqua.duke.edu 2.6.18-194.3.1.el5 #1 SMP Thu May 13
13:08:30 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux


This is the compiler

gfortran44 --version 
GNU Fortran (GCC) 4.4.0 20090514 (Red Hat 4.4.0-6)
Copyright (C) 2009 Free Software Foundation, Inc.


This is the problem

The bug is that the mask is supposed to be applied before the statements
within the where clause are evaluated.  As can be seen from the output
the statements within the mask are evaluated before the mask is applied.


This is the relevant code

do k = 1, rows + 1

      if ( (k .gt. rows) .or. (k .gt. cols) ) then
        mask = .false.
      else
        mask  = .true.
      end if

      where (mask)
        A = b(k) 
      end where

end do


These are the compiler flags

-save-temps -fbounds-check


This is stderr

At line 39 of file wherebug.F90
Fortran runtime error: Array reference out of bounds for array 'b',
upper bound of dimension 1 exceeded (6 > 5)

This is the -save-temps file

arg@argux9$ cat  wherebug.f90
# 1 "wherebug.F90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "wherebug.F90"
program wherebug
implicit none

integer, parameter ::   &
  stdin     =  5,       &  ! reserved unit for standard input
  stdout    =  6,       &  ! reserved unit for standard output
  stderr    =  0           ! reserved unit for standard error

integer, parameter ::                            &
  i1 = selected_int_kind(2),                     &
  i2 = selected_int_kind(4),                     &
  i4 = selected_int_kind(9),                     &
  i8 = selected_int_kind(18),                    &
  r4 = kind(1.0),                                &
  r8 = selected_real_kind(2*precision(1.0_r4)),  &
  r16 = selected_real_kind(2*precision(1.0_r8))

integer, parameter :: rows = 5, cols = 5

integer :: i, j, k

real(r8), dimension(rows,cols) :: A
real(r8), dimension(rows)      :: b
logical, dimension(rows,cols)  :: mask

A = 1.0_r8
b = 1.0_r8
mask = .true.

do k = 1, rows + 1

      if ( (k .gt. rows) .or. (k .gt. cols) ) then
        mask = .false.
      else
        mask  = .true.
      end if

      where (mask)
        A = b(k) 
      end where

end do

end program wherebug


-- 
           Summary: where mask not applied before where clause evaluated
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aronaldg at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45425


^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <bug-45425-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-12-18  1:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-27 10:03 [Bug fortran/45425] New: where mask not applied before where clause evaluated aronaldg at gmail dot com
2010-08-27 11:58 ` [Bug fortran/45425] Bounds check applied before MASK of WHERE construct burnus at gcc dot gnu dot org
2010-08-28 15:40 ` burnus at gcc dot gnu dot org
2010-08-28 17:43 ` mikael at gcc dot gnu dot org
2010-08-28 19:51 ` tkoenig at gcc dot gnu dot org
     [not found] <bug-45425-4@http.gcc.gnu.org/bugzilla/>
2021-12-18  1:26 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).