public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2
@ 2014-03-14  8:15 roger.ferrer at bsc dot es
  2014-03-14 19:14 ` [Bug fortran/60522] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: roger.ferrer at bsc dot es @ 2014-03-14  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60522
           Summary: WHERE construct causes an ICE in gfc_trans_where_2
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roger.ferrer at bsc dot es

Hi,

the following code

! -- test.f90
subroutine foo(a, b)
   implicit none
   integer, dimension(:), intent(inout) :: a
   integer, dimension(:), intent(in) :: b

   where (b(:) > 0)
      a(lbound(a, 1):ubound(a, 1)) = b(lbound(b, 1):ubound(b, 1)) * b(lbound(b,
1):ubound(b, 1))
   end where
end subroutine foo
! -- end of test.f90

causes an ICE if optimization is enabled:

$ gfortran -c test.f90 -O
test.f90: In function ‘foo’:
test.f90:6:0: internal compiler error: in gfc_trans_where_2, at
fortran/trans-stmt.c:4550
    where (B(:) > 0)
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.

The problem goes away if the assignment is of the (equivalent) form:

 a(:) = b(:) * b(:)

or

 a = b * b

or if optimization is disabled.

Kind regards,
>From gcc-bugs-return-446262-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Mar 14 08:18:32 2014
Return-Path: <gcc-bugs-return-446262-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21874 invoked by alias); 14 Mar 2014 08:18:32 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21849 invoked by uid 48); 14 Mar 2014 08:18:28 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/60521] std::lock_guard ignores adopt_lock strategy
Date: Fri, 14 Mar 2014 08:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.8.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed bug_severity
Message-ID: <bug-60521-4-KGn6QDAbzj@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60521-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60521-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-03/txt/msg01131.txt.bz2
Content-length: 735

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`521

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-03-14
     Ever confirmed|0                           |1
           Severity|blocker                     |normal

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Sergei Turchanov from comment #0)
>       lock_guard(mutex_type& __m, adopt_lock_t) : _M_device(__m)
>       { } // calling thread owns mutex

Where in that code do you think it locks the mutex?


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

* [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2
  2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
@ 2014-03-14 19:14 ` dominiq at lps dot ens.fr
  2014-03-14 20:20 ` mikael at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-03-14 19:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|WHERE construct causes an   |[4.7/4.8/4.9 Regression]
                   |ICE in gfc_trans_where_2    |WHERE construct causes an
                   |                            |ICE in gfc_trans_where_2

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Forgot to mark the PR as a regression. The ICE is due to the gcc_unreachable at

            default:
              gcc_unreachable ();

meaning that cnext->op has not one of the expected values in the switch.


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

* [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2
  2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
  2014-03-14 19:14 ` [Bug fortran/60522] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
@ 2014-03-14 20:20 ` mikael at gcc dot gnu.org
  2014-03-14 23:24 ` tkoenig at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-03-14 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
BLOCK constructs are not allowed inside WHERE constructs.
Thus, the "common function optimization" should not create a BLOCK to hold the
temporary variables, at least not inside WHERE.

Another possible fix, the following patch disables the optimization inside
WHERE.

diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 52bd700..dc641de 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -630,9 +630,16 @@ static int
 cfe_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED,
       void *data ATTRIBUTE_UNUSED)
 {
-  current_code = c;
-  inserted_block = NULL;
-  changed_statement = NULL;
+  /* BLOCK constructs cannot appear inside WHERE blocks; as the optimization
+     may introduce the former we disable it inside the latter.  */
+  if ((*c)->op == EXEC_WHERE)
+    *walk_subtrees = 0;
+  else
+    {
+      current_code = c;
+      inserted_block = NULL;
+      changed_statement = NULL;
+    }
   return 0;
 }


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

* [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2
  2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
  2014-03-14 19:14 ` [Bug fortran/60522] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
  2014-03-14 20:20 ` mikael at gcc dot gnu.org
@ 2014-03-14 23:24 ` tkoenig at gcc dot gnu.org
  2014-03-27 22:22 ` tkoenig at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2014-03-14 23:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #3)
> BLOCK constructs are not allowed inside WHERE constructs.
> Thus, the "common function optimization" should not create a BLOCK to hold
> the temporary variables, at least not inside WHERE.

Possible.

> Another possible fix, the following patch disables the optimization inside
> WHERE.

Not preferred, I'd like to continue the optimization.

I'll take a look.


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

* [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2
  2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
                   ` (2 preceding siblings ...)
  2014-03-14 23:24 ` tkoenig at gcc dot gnu.org
@ 2014-03-27 22:22 ` tkoenig at gcc dot gnu.org
  2014-03-28  7:17 ` tkoenig at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2014-03-27 22:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Author: tkoenig
Date: Thu Mar 27 22:21:35 2014
New Revision: 208883

URL: http://gcc.gnu.org/viewcvs?rev=208883&root=gcc&view=rev
Log:
2014-04-27  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/60522
    * frontend-passes.c (cfe_code):  Do not walk subtrees
    for WHERE.

2014-04-27  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/60522
    * gfortran.dg/where_4.f90:  New test case.


Added:
    trunk/gcc/testsuite/gfortran.dg/where_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2
  2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
                   ` (3 preceding siblings ...)
  2014-03-27 22:22 ` tkoenig at gcc dot gnu.org
@ 2014-03-28  7:17 ` tkoenig at gcc dot gnu.org
  2014-03-29 11:51 ` tkoenig at gcc dot gnu.org
  2014-03-29 11:53 ` tkoenig at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2014-03-28  7:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Author: tkoenig
Date: Fri Mar 28 07:17:13 2014
New Revision: 208890

URL: http://gcc.gnu.org/viewcvs?rev=208890&root=gcc&view=rev
Log:
2014-04-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/60522
    * frontend-passes.c (cfe_code):  Do not walk subtrees
    for WHERE.

2014-04-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/60522
    * gfortran.dg/where_4.f90:  New test case.


Added:
    branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/where_4.f90
Modified:
    branches/gcc-4_8-branch/gcc/fortran/ChangeLog
    branches/gcc-4_8-branch/gcc/fortran/frontend-passes.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2
  2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
                   ` (4 preceding siblings ...)
  2014-03-28  7:17 ` tkoenig at gcc dot gnu.org
@ 2014-03-29 11:51 ` tkoenig at gcc dot gnu.org
  2014-03-29 11:53 ` tkoenig at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2014-03-29 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Author: tkoenig
Date: Sat Mar 29 11:51:17 2014
New Revision: 208934

URL: http://gcc.gnu.org/viewcvs?rev=208934&root=gcc&view=rev
Log:
2014-04-29  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/60522
    * frontend-passes.c (cfe_code):  Do not walk subtrees
    for WHERE.

2014-04-29  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/60522
    * gfortran.dg/where_4.f90:  New test case.


Added:
    branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/where_4.f90
Modified:
    branches/gcc-4_7-branch/gcc/fortran/ChangeLog
    branches/gcc-4_7-branch/gcc/fortran/frontend-passes.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/60522] [4.7/4.8/4.9 Regression] WHERE construct causes an ICE in gfc_trans_where_2
  2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
                   ` (5 preceding siblings ...)
  2014-03-29 11:51 ` tkoenig at gcc dot gnu.org
@ 2014-03-29 11:53 ` tkoenig at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2014-03-29 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

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

--- Comment #8 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Fixed on all open branches, closing.


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

end of thread, other threads:[~2014-03-29 11:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-14  8:15 [Bug fortran/60522] New: WHERE construct causes an ICE in gfc_trans_where_2 roger.ferrer at bsc dot es
2014-03-14 19:14 ` [Bug fortran/60522] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
2014-03-14 20:20 ` mikael at gcc dot gnu.org
2014-03-14 23:24 ` tkoenig at gcc dot gnu.org
2014-03-27 22:22 ` tkoenig at gcc dot gnu.org
2014-03-28  7:17 ` tkoenig at gcc dot gnu.org
2014-03-29 11:51 ` tkoenig at gcc dot gnu.org
2014-03-29 11:53 ` tkoenig 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).