public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55214] New: Program fail to evaluate where clause
@ 2012-11-05 13:58 pmarguinaud at hotmail dot com
  2012-11-05 14:03 ` [Bug fortran/55214] " pmarguinaud at hotmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pmarguinaud at hotmail dot com @ 2012-11-05 13:58 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55214
           Summary: Program fail to evaluate where clause
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pmarguinaud@hotmail.com


LOGICAL :: L (2)
REAL    :: X (2), Y (2)

L (1) = .TRUE.
L (2) = .FALSE.
X (1) = +1
X (2) = -1
Y = 0.

WHERE (L)
  WHERE (SQRT(X)>0)
    Y = 1.
  END WHERE
END WHERE

PRINT *, Y

END


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

* [Bug fortran/55214] Program fail to evaluate where clause
  2012-11-05 13:58 [Bug fortran/55214] New: Program fail to evaluate where clause pmarguinaud at hotmail dot com
@ 2012-11-05 14:03 ` pmarguinaud at hotmail dot com
  2012-11-05 14:57 ` burnus at gcc dot gnu.org
  2021-12-18  4:23 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pmarguinaud at hotmail dot com @ 2012-11-05 14:03 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from pmarguinaud at hotmail dot com 2012-11-05 14:03:32 UTC ---
$ gfortran -g -O0 -ffpe-trap=invalid -static where.F90
$ ./a.out 

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

Backtrace for this error:
#0  0x40FBFD in _gfortrani_show_backtrace at backtrace.c:260
#1  0x400676 in _gfortrani_backtrace_handler at compile_options.c:129
#2  0x42996F in raise
#3  0x4004C7 in MAIN__ at where.F90:10
Exception en point flottant

Tested with gfortran 4.6.1 and latest 4.7; it looks like SQRT(X) is evaluated
where L is false.


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

* [Bug fortran/55214] Program fail to evaluate where clause
  2012-11-05 13:58 [Bug fortran/55214] New: Program fail to evaluate where clause pmarguinaud at hotmail dot com
  2012-11-05 14:03 ` [Bug fortran/55214] " pmarguinaud at hotmail dot com
@ 2012-11-05 14:57 ` burnus at gcc dot gnu.org
  2021-12-18  4:23 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-11-05 14:57 UTC (permalink / raw)
  To: gcc-bugs


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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-11-05
                 CC|                            |burnus at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-11-05 14:56:56 UTC ---
Confirmed - and not a regression as it also fails with GCC 4.1.

>From the C-like dump file (use -fdump-tree-original to create it):

For WHERE (L), one has:
            cond.3 = (logical(kind=1)) l[S.2 + -1];
            temp.0[count.1] = cond.3;

Which is then used in WHERE (SQRT(X)>0):

            cond.7 = __builtin_sqrtf (x[S.6 + -1]) > 0.0;
            mask.8 = temp.0[count.5];
            temp.4[count.5] = mask.8 && cond.7;

The proper way would be:
   mask.8 = temp.0[count.5];
   temp.4[count.5] = mask.8 ? __builtin_sqrtf (x[S.6 + -1]) > 0.0 : mask.8;

That is, the condition only gets evaluated if the outer mask is true.


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

* [Bug fortran/55214] Program fail to evaluate where clause
  2012-11-05 13:58 [Bug fortran/55214] New: Program fail to evaluate where clause pmarguinaud at hotmail dot com
  2012-11-05 14:03 ` [Bug fortran/55214] " pmarguinaud at hotmail dot com
  2012-11-05 14:57 ` burnus at gcc dot gnu.org
@ 2021-12-18  4:23 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ 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=55214

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gmx dot de

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 64097 has been marked as a duplicate of this bug. ***

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 13:58 [Bug fortran/55214] New: Program fail to evaluate where clause pmarguinaud at hotmail dot com
2012-11-05 14:03 ` [Bug fortran/55214] " pmarguinaud at hotmail dot com
2012-11-05 14:57 ` burnus at gcc dot gnu.org
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).