This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/64097] New: Bug with nested WHERE constructs


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

            Bug ID: 64097
           Summary: Bug with nested WHERE constructs
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gmx dot de

I encountered a problem with nested WHERE constructs, which I discussed at

https://groups.google.com/forum/#!topic/comp.lang.fortran/EG2k49ujggA

It appears that the evaluated of inner masks may not be treated (i.e. masked)
properly.

Example code:

% cat nested-where.f90
program nested_where
  implicit none
  integer, parameter :: n = 100
  real               :: x(n), y(n)
  real               :: z = log (0.5)
  call random_number (x)
  y = 1                   ! "Good initialization"
  y = 0                   ! "Bad  initialization"
  print *, count (x == 1) ! Prints 0
  where (x > 0.5)
     y = x
     where (log (y) > z)  ! The "dangerous mask"
        x = 1
     end where
  end where
  print *, count (x == 1) ! Not reached for y=0
end program nested_where

The code works with NAG, PGI and xlf.  It throws an FP exception when
evaluating the inner ("dangerous") mask with GCC, Intel and Crayftn,
provided FP exceptions for invalid are enabled.

Ian Harvey cited sentence 10 in section 7.2.3.2 of the standard
document, which appears to deal with this case.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]