public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/64097] New: Bug with nested WHERE constructs
@ 2014-11-27 21:45 anlauf at gmx dot de
  2015-10-10 10:56 ` [Bug fortran/64097] " dominiq at lps dot ens.fr
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: anlauf at gmx dot de @ 2014-11-27 21:45 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/64097] Bug with nested WHERE constructs
  2014-11-27 21:45 [Bug fortran/64097] New: Bug with nested WHERE constructs anlauf at gmx dot de
@ 2015-10-10 10:56 ` dominiq at lps dot ens.fr
  2015-10-10 11:46 ` anlauf at gmx dot de
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-10 10:56 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-10-10
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
WORKSFORME on x86_64-apple-darwin14 with 4.8 up to trunk (6.0) and the various
options I tried:

[Book15] f90/bug% gfortran pr64097.f90 -fcheck=all -fsanitize=address
[Book15] f90/bug% a.out
           0
          58

gfortran is 5.2.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/64097] Bug with nested WHERE constructs
  2014-11-27 21:45 [Bug fortran/64097] New: Bug with nested WHERE constructs anlauf at gmx dot de
  2015-10-10 10:56 ` [Bug fortran/64097] " dominiq at lps dot ens.fr
@ 2015-10-10 11:46 ` anlauf at gmx dot de
  2015-10-10 12:10 ` dominiq at lps dot ens.fr
  2021-12-18  4:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gmx dot de @ 2015-10-10 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Dominique d'Humieres from comment #1)
> WORKSFORME on x86_64-apple-darwin14 with 4.8 up to trunk (6.0) and the
> various options I tried:
> 
> [Book15] f90/bug% gfortran pr64097.f90 -fcheck=all -fsanitize=address
> [Book15] f90/bug% a.out
>            0
>           58
> 
> gfortran is 5.2.

I think the trapping of exceptions must be enabled.

% gfortran --version
GNU Fortran (GCC) 5.1.0

% gfortran -O -march=native -g -ffpe-trap=zero,overflow,invalid
nested-where.f90 && ./a.out 
           0

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic
operation.

Backtrace for this error:
#0  0x7F09C1E59B97
#1  0x7F09C1E58D90
#2  0x7F09C1430F4F
#3  0x7F09C1BE7277
#4  0x7F09C1BEBE50
#5  0x400A34 in MAIN__ at nested-where.f90:0
Floating exception


Without -ffpe-trap=... I get the same as you.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/64097] Bug with nested WHERE constructs
  2014-11-27 21:45 [Bug fortran/64097] New: Bug with nested WHERE constructs anlauf at gmx dot de
  2015-10-10 10:56 ` [Bug fortran/64097] " dominiq at lps dot ens.fr
  2015-10-10 11:46 ` anlauf at gmx dot de
@ 2015-10-10 12:10 ` dominiq at lps dot ens.fr
  2021-12-18  4:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-10 12:10 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
      Known to fail|                            |4.8.5, 4.9.3, 5.2.0, 6.0

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> I think the trapping of exceptions must be enabled.

Confirmed.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/64097] Bug with nested WHERE constructs
  2014-11-27 21:45 [Bug fortran/64097] New: Bug with nested WHERE constructs anlauf at gmx dot de
                   ` (2 preceding siblings ...)
  2015-10-10 12:10 ` dominiq at lps dot ens.fr
@ 2021-12-18  4:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-18  4:23 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 55214.

*** This bug has been marked as a duplicate of bug 55214 ***

^ permalink raw reply	[flat|nested] 5+ messages in thread

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-27 21:45 [Bug fortran/64097] New: Bug with nested WHERE constructs anlauf at gmx dot de
2015-10-10 10:56 ` [Bug fortran/64097] " dominiq at lps dot ens.fr
2015-10-10 11:46 ` anlauf at gmx dot de
2015-10-10 12:10 ` dominiq at lps dot ens.fr
2021-12-18  4:23 ` 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).