public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/38907]  New: ICE when contained function has same name as module function and used in expression
@ 2009-01-18 21:21 dick dot hendrickson at gmail dot com
  2009-01-18 21:44 ` [Bug fortran/38907] " kargl at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: dick dot hendrickson at gmail dot com @ 2009-01-18 21:21 UTC (permalink / raw)
  To: gcc-bugs

The following program gives an internal compiler error.  If the line
RDA = -1 is commented out, there is a different ICE.  If the unary +
before the function reference in the assignment to RDA(1,2) is removed
the ICE goes away.

Dick Hendrickson


      module sa0054_stuff

! fails on Windows XP
! gcc version 4.4.0 20081219 (experimental) [trunk revision 142842] (GCC)

      contains

      PURE FUNCTION S_REAL_SUM_I (A,B)
      REAL  ::  S_REAL_SUM_I
      REAL, INTENT(IN), OPTIONAL  ::  A,B
      X = 0
      S_REAL_SUM_I = X

      END FUNCTION S_REAL_SUM_I

      SUBROUTINE SA0054(RDA, NF10,nf1,nf2,nf3,nf4)
      REAL RDA(NF10,NF10)

      RDA    = -1                  !changes ICE if commented out

          RDA(1,2) = + S_REAL_SUM_I(1.0,2.0)

!         RDA(1,2) =   S_REAL_SUM_I(1.0,2.0)     !This one works

      CONTAINS

      PURE FUNCTION S_REAL_SUM_I (A,B)
      REAL  ::  S_REAL_SUM_I
      REAL, INTENT(IN), OPTIONAL  ::  A,B
      S_REAL_SUM_I = 0
      END FUNCTION S_REAL_SUM_I

      END SUBROUTINE

      end module sa0054_stuff


With RDA = -1
C:\gfortran>gfortran try_sa0054.f
f951.exe: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


With RDA = -1 commented out
C:\gfortran>gfortran try_sa0054.f
f951.exe: internal compiler error: in check_host_association, at
fortran/resolve
.c:4369
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


-- 
           Summary: ICE when contained function has same name as module
                    function and used in expression
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dick dot hendrickson at gmail dot com


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


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

* [Bug fortran/38907] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
@ 2009-01-18 21:44 ` kargl at gcc dot gnu dot org
  2009-01-18 21:47 ` [Bug fortran/38907] [regression 4.3/4.4] " kargl at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-01-18 21:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kargl at gcc dot gnu dot org  2009-01-18 21:44 -------
Confirmed for both ICEs.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-01-18 21:44:29
               date|                            |


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


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

* [Bug fortran/38907] [regression 4.3/4.4] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
  2009-01-18 21:44 ` [Bug fortran/38907] " kargl at gcc dot gnu dot org
  2009-01-18 21:47 ` [Bug fortran/38907] [regression 4.3/4.4] " kargl at gcc dot gnu dot org
@ 2009-01-18 21:47 ` kargl at gcc dot gnu dot org
  2009-01-18 22:28 ` [Bug fortran/38907] [4.3/4.4 Regression ] " burnus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-01-18 21:47 UTC (permalink / raw)
  To: gcc-bugs



-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sgk at troutmask dot apl dot
                   |                            |washington dot edu
           Priority|P3                          |P4


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


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

* [Bug fortran/38907] [regression 4.3/4.4] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
  2009-01-18 21:44 ` [Bug fortran/38907] " kargl at gcc dot gnu dot org
@ 2009-01-18 21:47 ` kargl at gcc dot gnu dot org
  2009-01-18 21:47 ` kargl at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-01-18 21:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kargl at gcc dot gnu dot org  2009-01-18 21:47 -------
Both variations of the program work with 4.2.5, so this is
a regression.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.3.3 4.4.0
      Known to work|                            |4.2.5
            Summary|ICE when contained function |[regression 4.3/4.4] ICE
                   |has same name as module     |when contained function has
                   |function and used in        |same name as module function
                   |expression                  |and used in expression


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


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

* [Bug fortran/38907] [4.3/4.4 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (2 preceding siblings ...)
  2009-01-18 21:47 ` kargl at gcc dot gnu dot org
@ 2009-01-18 22:28 ` burnus at gcc dot gnu dot org
  2009-01-19 22:34 ` mikael at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-01-18 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2009-01-18 22:27 -------
Confirm. Thanks for the report!

Valgrind shows:

==20941== Conditional jump or move depends on uninitialised value(s)
==20941==    at 0x46C602: gfc_resolve_expr (resolve.c:4353)
==20941==    by 0x46BC22: gfc_resolve_expr (resolve.c:3057)
==20941==    by 0x472944: resolve_code (resolve.c:6676)

==20941== Use of uninitialised value of size 8
==20941==    at 0x46C608: gfc_resolve_expr (resolve.c:4353)

==20941== Invalid read of size 8
==20941==    at 0x46C608: gfc_resolve_expr (resolve.c:4353)

That line is:

  4349            gfc_match_rvalue (&expr);
  4350            gfc_clear_error ();
  4351            gfc_buffer_error (0);
  4352
  4353            gcc_assert (expr && sym == expr->symtree->n.sym);

I added some debug printfs and valgrind shows invalid reads for:
  expr == NULL
and
  expr->symtree
where the latter results in a segfault.

I think the problem occurs if gfc_match_rvalue does not match. Then the
argument "&expr" will remain unmodified.

If one applies the following patch, the compilation will fail with the bogus
error

          RDA(1,2) = + S_REAL_SUM_I(1.0,2.0)
                                   1
Error: Unclassifiable statement at (1)


--- resolve.c   (Revision 143486)
+++ resolve.c
@@ -4348,3 +4348,4 @@ check_host_association (gfc_expr *e)
    only integers and vectors can be involved.  */
-         gfc_match_rvalue (&expr);
+         if (gfc_match_rvalue (&expr) == MATCH_YES)
+           {
          gfc_clear_error ();
@@ -4359,2 +4360,3 @@ check_host_association (gfc_expr *e)
          gfc_current_locus = temp_locus;
+           }
        }


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |32834
              nThis|                            |
           Keywords|                            |ice-on-valid-code
      Known to work|4.2.5                       |4.2.5 4.3.1
            Summary|[regression 4.3/4.4] ICE    |[4.3/4.4 Regression ] ICE
                   |when contained function has |when contained function has
                   |same name as module function|same name as module function
                   |and used in expression      |and used in expression
   Target Milestone|---                         |4.3.4


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


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

* [Bug fortran/38907] [4.3/4.4 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (3 preceding siblings ...)
  2009-01-18 22:28 ` [Bug fortran/38907] [4.3/4.4 Regression ] " burnus at gcc dot gnu dot org
@ 2009-01-19 22:34 ` mikael at gcc dot gnu dot org
  2009-01-19 22:40 ` dominiq at lps dot ens dot fr
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mikael at gcc dot gnu dot org @ 2009-01-19 22:34 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 683 bytes --]



------- Comment #4 from mikael at gcc dot gnu dot org  2009-01-19 22:33 -------
This removes the ICE:

Index: primary.c
===================================================================
--- primary.c   (révision 143501)
+++ primary.c   (copie de travail)
@@ -2370,6 +2370,8 @@
   bool implicit_char;
   gfc_ref *ref;

+  where = gfc_current_locus;
+
   m = gfc_match_name (name);
   if (m != MATCH_YES)
     return m;
@@ -2385,7 +2387,6 @@

   sym = symtree->n.sym;
   e = NULL;
-  where = gfc_current_locus;

   /* If this is an implicit do loop index and implicitly typed,
      it should not be host associated.  */


-- 


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


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

* [Bug fortran/38907] [4.3/4.4 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (4 preceding siblings ...)
  2009-01-19 22:34 ` mikael at gcc dot gnu dot org
@ 2009-01-19 22:40 ` dominiq at lps dot ens dot fr
  2009-01-19 23:08 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-01-19 22:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dominiq at lps dot ens dot fr  2009-01-19 22:39 -------
> This removes the ICE: ...

Do you understand why?


-- 


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


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

* [Bug fortran/38907] [4.3/4.4 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (5 preceding siblings ...)
  2009-01-19 22:40 ` dominiq at lps dot ens dot fr
@ 2009-01-19 23:08 ` pault at gcc dot gnu dot org
  2009-01-20 19:48 ` mikael at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-19 23:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2009-01-19 23:08 -------
Created an attachment (id=17148)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17148&action=view)
A patch for the PR

This regtests and bootstraps on FC9/x86_i64.  I'll do ChangeLogs and so on
tomorrow.

Thanks for the report, Dick!

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug fortran/38907] [4.3/4.4 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (6 preceding siblings ...)
  2009-01-19 23:08 ` pault at gcc dot gnu dot org
@ 2009-01-20 19:48 ` mikael at gcc dot gnu dot org
  2009-01-20 21:57 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mikael at gcc dot gnu dot org @ 2009-01-20 19:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mikael at gcc dot gnu dot org  2009-01-20 19:48 -------
(In reply to comment #5)
> > This removes the ICE: ...
> 
> Do you understand why?
> 
In the following:
          RDA(1,2) = + S_REAL_SUM_I(1.0,2.0)

gfc_match_rvalue sets where for the rhs to the marked position below:
          RDA(1,2) = + S_REAL_SUM_I(1.0,2.0)
                                   ^
check_host_association (before Paul's patch) calls gfc_match_rvalue again
starting at the e->where position (which is wrong). The match fails and there
is no code to handle it as it is unexpected. 

With my patch where is set at the beginning of the function name, permitting
proper match. This patch is needed I think, independently of Paul's one. For
4.5 if I don't forget about it. 


-- 


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


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

* [Bug fortran/38907] [4.3/4.4 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (7 preceding siblings ...)
  2009-01-20 19:48 ` mikael at gcc dot gnu dot org
@ 2009-01-20 21:57 ` pault at gcc dot gnu dot org
  2009-01-20 21:59 ` [Bug fortran/38907] [4.3 " pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-20 21:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pault at gcc dot gnu dot org  2009-01-20 21:57 -------
Subject: Bug 38907

Author: pault
Date: Tue Jan 20 21:56:49 2009
New Revision: 143530

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143530
Log:
2009-01-20  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/38907
        * resolve.c (check_host_association): Remove the matching to
        correct an incorrect host association and use manipulation of
        the expression instead.

2009-01-20  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/38907
        * gfortran.dg/host_assoc_function_7.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/host_assoc_function_7.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/38907] [4.3 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (8 preceding siblings ...)
  2009-01-20 21:57 ` pault at gcc dot gnu dot org
@ 2009-01-20 21:59 ` pault at gcc dot gnu dot org
  2009-01-26  6:16 ` pault at gcc dot gnu dot org
  2009-01-26  6:16 ` pault at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-20 21:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pault at gcc dot gnu dot org  2009-01-20 21:59 -------
Fixed on trunk

Thanks for the report.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.3/4.4 Regression ] ICE   |[4.3 Regression ] ICE when
                   |when contained function has |contained function has same
                   |same name as module function|name as module function and
                   |and used in expression      |used in expression


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


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

* [Bug fortran/38907] [4.3 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (10 preceding siblings ...)
  2009-01-26  6:16 ` pault at gcc dot gnu dot org
@ 2009-01-26  6:16 ` pault at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-26  6:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from pault at gcc dot gnu dot org  2009-01-26 06:16 -------
Fixed on trunk and 4.3

Thanks for the report and thanks to Mikael for the fix.

Paul


-- 

pault at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/38907] [4.3 Regression ] ICE when contained function has same name as module function and used in expression
  2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
                   ` (9 preceding siblings ...)
  2009-01-20 21:59 ` [Bug fortran/38907] [4.3 " pault at gcc dot gnu dot org
@ 2009-01-26  6:16 ` pault at gcc dot gnu dot org
  2009-01-26  6:16 ` pault at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-26  6:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pault at gcc dot gnu dot org  2009-01-26 06:15 -------
Subject: Bug 38907

Author: pault
Date: Mon Jan 26 06:15:41 2009
New Revision: 143671

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143671
Log:
2009-01-26  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/38907
        Backport from trunk
        * resolve.c (check_host_association): Remove the matching to
        correct an incorrect host association and use manipulation of
        the expression instead.

2009-01-26  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/38907
        Backport from trunk
        * gfortran.dg/host_assoc_function_7.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/host_assoc_function_7.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/resolve.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


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

end of thread, other threads:[~2009-01-26  6:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-18 21:21 [Bug fortran/38907] New: ICE when contained function has same name as module function and used in expression dick dot hendrickson at gmail dot com
2009-01-18 21:44 ` [Bug fortran/38907] " kargl at gcc dot gnu dot org
2009-01-18 21:47 ` [Bug fortran/38907] [regression 4.3/4.4] " kargl at gcc dot gnu dot org
2009-01-18 21:47 ` kargl at gcc dot gnu dot org
2009-01-18 22:28 ` [Bug fortran/38907] [4.3/4.4 Regression ] " burnus at gcc dot gnu dot org
2009-01-19 22:34 ` mikael at gcc dot gnu dot org
2009-01-19 22:40 ` dominiq at lps dot ens dot fr
2009-01-19 23:08 ` pault at gcc dot gnu dot org
2009-01-20 19:48 ` mikael at gcc dot gnu dot org
2009-01-20 21:57 ` pault at gcc dot gnu dot org
2009-01-20 21:59 ` [Bug fortran/38907] [4.3 " pault at gcc dot gnu dot org
2009-01-26  6:16 ` pault at gcc dot gnu dot org
2009-01-26  6:16 ` pault 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).