public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31259]  New: ICE on elemental character function
@ 2007-03-19  0:58 fxcoudert at gcc dot gnu dot org
  2007-03-29 10:44 ` [Bug fortran/31259] " pault at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-19  0:58 UTC (permalink / raw)
  To: gcc-bugs

gfortran ICEs on the following invalid code:

  print *, len(bar([2,3,4,5]))
contains
  elemental function bar(i)
    integer, intent(in) :: i
    character(len=i) :: bar
    bar = ""
  end function bar
end

We should simply reject i being used in an initialization expr.


-- 
           Summary: ICE on elemental character function
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org


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


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

* [Bug fortran/31259] ICE on elemental character function
  2007-03-19  0:58 [Bug fortran/31259] New: ICE on elemental character function fxcoudert at gcc dot gnu dot org
@ 2007-03-29 10:44 ` pault at gcc dot gnu dot org
  2007-07-17 10:38 ` dfranke at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-29 10:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pault at gcc dot gnu dot org  2007-03-29 11:44 -------
Yes, indeed; a dummy argument of an elemental procedure cannot appear in a
specification expression.

12.7.1
Constraint: A dummy argument, or a subobject thereof, shall not appear in a
specification-expr except as the argument to one of the intrinsic functions
BIT_SIZE, KIND, LEN, or the numeric inquiry functions (13.11.8).

Confirmed

Paul


-- 

pault 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         |2007-03-29 11:44:01
               date|                            |


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


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

* [Bug fortran/31259] ICE on elemental character function
  2007-03-19  0:58 [Bug fortran/31259] New: ICE on elemental character function fxcoudert at gcc dot gnu dot org
  2007-03-29 10:44 ` [Bug fortran/31259] " pault at gcc dot gnu dot org
@ 2007-07-17 10:38 ` dfranke at gcc dot gnu dot org
  2007-07-24 13:28 ` burnus at gcc dot gnu dot org
  2007-10-19 23:21 ` jvdelisle at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-07-17 10:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dfranke at gcc dot gnu dot org  2007-07-17 10:38 -------
Please note that the problem is not limited to character functions:

$> cat pr31529.f90
print *, bar((/2, 3/))
contains
  elemental function bar(i)
    integer, intent(in) :: i
    integer :: a(i:i)
    a = i
    bar = a(i)
  end function bar
end

Here, dummy I is used as specification expression in array bounds and accepted
by gfortran (20070716). Although there is no ICE and the result is as one would
expect, the code is still invalid.


-- 

dfranke at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/31259] ICE on elemental character function
  2007-03-19  0:58 [Bug fortran/31259] New: ICE on elemental character function fxcoudert at gcc dot gnu dot org
  2007-03-29 10:44 ` [Bug fortran/31259] " pault at gcc dot gnu dot org
  2007-07-17 10:38 ` dfranke at gcc dot gnu dot org
@ 2007-07-24 13:28 ` burnus at gcc dot gnu dot org
  2007-10-19 23:21 ` jvdelisle at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-07-24 13:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-07-24 13:28 -------
The following patch works for the original example; it also works in principle
for the additional example, but there the error message is printed three times.

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c  (revision 126873)
+++ gcc/fortran/expr.c  (working copy)
@@ -2397,6 +2397,15 @@
          break;
        }

+      if (sym->attr.dummy && sym->ns->proc_name != NULL
+         && sym->ns->proc_name->attr.elemental)
+       {
+         gfc_error ("Dummy argument '%s' of elemental function '%s' "
+                    "cannot appear in a specification expression at %L",
+                    sym->name, sym->ns->proc_name->name, &e->where);
+         break;
+       }
+
       /* gfc_is_formal_arg broadcasts that a formal argument list is being
         processed in resolve.c(resolve_formal_arglist).  This is done so
         that host associated dummy array indices are accepted (PR23446).
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (revision 126873)
+++ gcc/fortran/resolve.c       (working copy)
@@ -3771,7 +3779,7 @@
          if (!seen)
            {
              if (specification_expr)
-               gfc_error ("Variable '%s',used in a specification expression, "
+               gfc_error ("Variable '%s', used in a specification expression,
"
                           "is referenced at %L before the ENTRY statement "
                           "in which it is a parameter",
                           sym->name, &cs_base->current->loc);


-- 

burnus at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/31259] ICE on elemental character function
  2007-03-19  0:58 [Bug fortran/31259] New: ICE on elemental character function fxcoudert at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-07-24 13:28 ` burnus at gcc dot gnu dot org
@ 2007-10-19 23:21 ` jvdelisle at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-10-19 23:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2007-10-19 23:21 -------
I see that this ICE has been fixed along the way.  For the test case in comment
#2 we still get three error messages, but this is because we do not disable
resolve.c and more than one code path gets taken.  There are more than one of
these situations.

I have experimented in the pass with fixes for this problem by disabling the
resolve phase when an error is encountered, but this leads to prolific
testsuite failures because we end up not doing a lot of error checking that is
by necessity, done in resolve.

Closing, since there is no ICE and it is invalid code.


-- 

jvdelisle at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-10-19 23:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-19  0:58 [Bug fortran/31259] New: ICE on elemental character function fxcoudert at gcc dot gnu dot org
2007-03-29 10:44 ` [Bug fortran/31259] " pault at gcc dot gnu dot org
2007-07-17 10:38 ` dfranke at gcc dot gnu dot org
2007-07-24 13:28 ` burnus at gcc dot gnu dot org
2007-10-19 23:21 ` jvdelisle 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).