public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33354]  New: MINLOC in combination with SUM gives wrong result
@ 2007-09-08 13:02 enok at lysator dot liu dot se
  2007-09-08 15:31 ` [Bug fortran/33354] " kargl at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: enok at lysator dot liu dot se @ 2007-09-08 13:02 UTC (permalink / raw)
  To: gcc-bugs

A simple program should print "1" but prints "2". Of some reason MINLOC fails
to find the minium location (first location) for the SUM expression.

PROGRAM TST
  IMPLICIT NONE
  REAL :: A(1,3)
  A(:,1) = 10
  A(:,2) = 20
  A(:,3) = 30
  WRITE(*,*) SUM(A(:,1:3),1)
  WRITE(*,*) MINLOC(SUM(A(:,1:3),1),1)
END PROGRAM TST

bash%> gfortran -o tst tst.f90
bash%> ./tst
   10.00000       20.00000       30.00000
           2
bash%>


-- 
           Summary: MINLOC in combination with SUM gives wrong result
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: enok at lysator dot liu dot se
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/33354] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
@ 2007-09-08 15:31 ` kargl at gcc dot gnu dot org
  2007-09-08 16:16 ` burnus at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-09-08 15:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kargl at gcc dot gnu dot org  2007-09-08 15:31 -------
The code compiles and runs correctly with trunk (aka 4.3).
I'm guessing that Thomas had fixed the problem and that
he did not back port the fix because the bug isn't a
regression.  If Thomas does not comment on the PR in a
reasonable time, I'm inclinded to cloase the PR.  Thanks
for the bug report.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu dot org


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


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

* [Bug fortran/33354] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
  2007-09-08 15:31 ` [Bug fortran/33354] " kargl at gcc dot gnu dot org
@ 2007-09-08 16:16 ` burnus at gcc dot gnu dot org
  2007-09-11 18:37 ` pault at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-08 16:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-09-08 16:16 -------
I want to add that you can find gfortran 4.3.0 binaries at
   http://gcc.gnu.org/wiki/GFortranBinaries

I'm actually unsure which patch fixed it. It might be Paul's PR32298 even
though it is about PARAMETER arrays.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.2.2
      Known to work|                            |4.3.0


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


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

* [Bug fortran/33354] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
  2007-09-08 15:31 ` [Bug fortran/33354] " kargl at gcc dot gnu dot org
  2007-09-08 16:16 ` burnus at gcc dot gnu dot org
@ 2007-09-11 18:37 ` pault at gcc dot gnu dot org
  2007-09-22  8:53 ` [Bug fortran/33354] [4.2 only] " tkoenig at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-09-11 18:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2007-09-11 18:37 -------
(In reply to comment #2)
> I want to add that you can find gfortran 4.3.0 binaries at
>    http://gcc.gnu.org/wiki/GFortranBinaries
> 
> I'm actually unsure which patch fixed it. It might be Paul's PR32298 even
> though it is about PARAMETER arrays.
> 

Nah! I plead not guilty:-)

Paul


-- 


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (2 preceding siblings ...)
  2007-09-11 18:37 ` pault at gcc dot gnu dot org
@ 2007-09-22  8:53 ` tkoenig at gcc dot gnu dot org
  2007-09-29  7:58 ` tobi at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-09-22  8:53 UTC (permalink / raw)
  To: gcc-bugs



-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkoenig at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-22 08:53:05
               date|                            |


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (3 preceding siblings ...)
  2007-09-22  8:53 ` [Bug fortran/33354] [4.2 only] " tkoenig at gcc dot gnu dot org
@ 2007-09-29  7:58 ` tobi at gcc dot gnu dot org
  2007-09-29  8:00 ` tobi at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-29  7:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tobi at gcc dot gnu dot org  2007-09-29 07:57 -------
Subject: Bug 33354

Author: tobi
Date: Sat Sep 29 07:57:37 2007
New Revision: 128882

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128882
Log:
PR fortran/33354
* gfortran.dg/minmaxloc_4.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/minmaxloc_4.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (4 preceding siblings ...)
  2007-09-29  7:58 ` tobi at gcc dot gnu dot org
@ 2007-09-29  8:00 ` tobi at gcc dot gnu dot org
  2007-09-29 13:12 ` tkoenig at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-09-29  8:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from tobi at gcc dot gnu dot org  2007-09-29 08:00 -------
I added a testcase for this.  Can this bug be closed or does anyone feel
strongly enough about it to fix it in 4.2?


-- 

tobi at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (5 preceding siblings ...)
  2007-09-29  8:00 ` tobi at gcc dot gnu dot org
@ 2007-09-29 13:12 ` tkoenig at gcc dot gnu dot org
  2007-09-30 20:56 ` enok at lysator dot liu dot se
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-09-29 13:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from tkoenig at gcc dot gnu dot org  2007-09-29 13:12 -------
(In reply to comment #5)
> I added a testcase for this.

Thanks!

> Can this bug be closed or does anyone feel
> strongly enough about it to fix it in 4.2?

If we can identify which patch fixed this, I'd be in favor
of backporting (even though we'll miss 4.2.2).

Thomas


-- 


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (6 preceding siblings ...)
  2007-09-29 13:12 ` tkoenig at gcc dot gnu dot org
@ 2007-09-30 20:56 ` enok at lysator dot liu dot se
  2007-09-30 21:03 ` tkoenig at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: enok at lysator dot liu dot se @ 2007-09-30 20:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from enok at lysator dot liu dot se  2007-09-30 20:56 -------
(In reply to comment #6)
> (In reply to comment #5)
> > I added a testcase for this.
> Thanks!
> > Can this bug be closed or does anyone feel
> > strongly enough about it to fix it in 4.2?
> If we can identify which patch fixed this, I'd be in favor
> of backporting (even though we'll miss 4.2.2).
> Thomas

I think it's a pretty serious bug. Everyone who uses MINLOC or MAXLOC will
silently get wrong result in certain cases and those intrinsics are fairly
commonly used. It would sure be nice if this could be fixed in 4.2.3, to bad
its to late for 4.2.2. Let me know if theres anything I can do to help.


-- 


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (7 preceding siblings ...)
  2007-09-30 20:56 ` enok at lysator dot liu dot se
@ 2007-09-30 21:03 ` tkoenig at gcc dot gnu dot org
  2007-10-02 18:09 ` tkoenig at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-09-30 21:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from tkoenig at gcc dot gnu dot org  2007-09-30 21:03 -------
I am currently trying to find the patch responsible
for fixing this.  This could indeed be Paul's
fix for PR 32298 and 31726.


-- 


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (8 preceding siblings ...)
  2007-09-30 21:03 ` tkoenig at gcc dot gnu dot org
@ 2007-10-02 18:09 ` tkoenig at gcc dot gnu dot org
  2007-10-02 18:51 ` tobi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-02 18:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from tkoenig at gcc dot gnu dot org  2007-10-02 18:09 -------
I can confirm that

http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125983

fixes the problem for 4.2.  As this is a particularly
bad (i.e. silent wrong-code) bug, I propose to commit
Paul's patch once 4.2 reopens.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tkoenig at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
           Keywords|                            |wrong-code
   Last reconfirmed|2007-09-22 08:53:05         |2007-10-02 18:09:13
               date|                            |


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (9 preceding siblings ...)
  2007-10-02 18:09 ` tkoenig at gcc dot gnu dot org
@ 2007-10-02 18:51 ` tobi at gcc dot gnu dot org
  2007-10-15 18:24 ` tkoenig at gcc dot gnu dot org
  2007-10-15 18:24 ` tkoenig at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: tobi at gcc dot gnu dot org @ 2007-10-02 18:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from tobi at gcc dot gnu dot org  2007-10-02 18:51 -------
There are only two later patches to min/maxloc, namely those for PRs 33297 and
32954, which both seem unrelated.  So I agree that this should be safe to
backport.


-- 


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (11 preceding siblings ...)
  2007-10-15 18:24 ` tkoenig at gcc dot gnu dot org
@ 2007-10-15 18:24 ` tkoenig at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-15 18:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from tkoenig at gcc dot gnu dot org  2007-10-15 18:24 -------
Fixed.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|4.3.0                       |4.3.0 4.2.3
         Resolution|                            |FIXED


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


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

* [Bug fortran/33354] [4.2 only] MINLOC in combination with SUM gives wrong result
  2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
                   ` (10 preceding siblings ...)
  2007-10-02 18:51 ` tobi at gcc dot gnu dot org
@ 2007-10-15 18:24 ` tkoenig at gcc dot gnu dot org
  2007-10-15 18:24 ` tkoenig at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-10-15 18:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from tkoenig at gcc dot gnu dot org  2007-10-15 18:23 -------
Subject: Bug 33354

Author: tkoenig
Date: Mon Oct 15 18:23:39 2007
New Revision: 129365

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129365
Log:
2007-10-25  Thomas Koenig  <tkoenig@gcc.gnu.org>
            Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/32298
        PR fortran/31726
        PR fortran/33354
        Backport from trunk
        * trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): Calculate
        the offset between the loop counter and the position as
        defined. Add the offset within the loop so that the mask acts
        correctly.  Do not advance the location on the basis that it
        is zero.

2007-10-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/33354
        * gfortran.dg/minmaxloc_4.f90:  New test.



Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/minmaxloc_4.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog


-- 


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


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

end of thread, other threads:[~2007-10-15 18:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-08 13:02 [Bug fortran/33354] New: MINLOC in combination with SUM gives wrong result enok at lysator dot liu dot se
2007-09-08 15:31 ` [Bug fortran/33354] " kargl at gcc dot gnu dot org
2007-09-08 16:16 ` burnus at gcc dot gnu dot org
2007-09-11 18:37 ` pault at gcc dot gnu dot org
2007-09-22  8:53 ` [Bug fortran/33354] [4.2 only] " tkoenig at gcc dot gnu dot org
2007-09-29  7:58 ` tobi at gcc dot gnu dot org
2007-09-29  8:00 ` tobi at gcc dot gnu dot org
2007-09-29 13:12 ` tkoenig at gcc dot gnu dot org
2007-09-30 20:56 ` enok at lysator dot liu dot se
2007-09-30 21:03 ` tkoenig at gcc dot gnu dot org
2007-10-02 18:09 ` tkoenig at gcc dot gnu dot org
2007-10-02 18:51 ` tobi at gcc dot gnu dot org
2007-10-15 18:24 ` tkoenig at gcc dot gnu dot org
2007-10-15 18:24 ` tkoenig at gcc dot gnu dot 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).