public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31822]  New: Missing run-time bound checks for character pointer => target
@ 2007-05-04 19:21 burnus at gcc dot gnu dot org
  2007-08-09 22:52 ` [Bug fortran/31822] " fxcoudert at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-05-04 19:21 UTC (permalink / raw)
  To: gcc-bugs

Test case. The comments show what NAG f95 -C=all prints at run time.

program ptr
  implicit none
  character(len=10), target :: s1
  character(len=5), pointer :: p1
  integer, volatile :: i
  i = 8
! Unequal character lengths (5 and 8) in pointer assignment
  p1 => s1(1:i)
  call bar(s1)
contains
  subroutine bar(s)
    character(len=*),target  :: s
    character(len=17),pointer :: p
! Unequal character lengths (17 and 10) in pointer assignment
    p => s
  end subroutine bar
end program ptr


-- 
           Summary: Missing run-time bound checks for character pointer =>
                    target
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 27766
             nThis:


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


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

* [Bug fortran/31822] Missing run-time bound checks for character pointer => target
  2007-05-04 19:21 [Bug fortran/31822] New: Missing run-time bound checks for character pointer => target burnus at gcc dot gnu dot org
@ 2007-08-09 22:52 ` fxcoudert at gcc dot gnu dot org
  2008-12-17  9:48 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-09 22:52 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert 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-08-09 22:52:00
               date|                            |


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


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

* [Bug fortran/31822] Missing run-time bound checks for character pointer => target
  2007-05-04 19:21 [Bug fortran/31822] New: Missing run-time bound checks for character pointer => target burnus at gcc dot gnu dot org
  2007-08-09 22:52 ` [Bug fortran/31822] " fxcoudert at gcc dot gnu dot org
@ 2008-12-17  9:48 ` burnus at gcc dot gnu dot org
  2008-12-17  9:57 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-12-17  9:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2008-12-17 09:46 -------
For completeness: The compile-time check works in gfortran
  character(len=10), target :: str
  character(len=5), pointer :: ptr
  ptr => str
  end
Error: Different character lengths in pointer assignment at (1)

However, I start to wonder whether that is actually valid? I know that it is
rejected (at compile time) by gfortran, ifort, NAG f95, g95, openf95, and
sunf95. However, if I read 7.4.2 of the Fortran 2003 standard I cannot find the
restriction. ifort prints:

error #6795: The target must be of the same type and kind type parameters as
the pointer.   [PTR]

And that is what I find in the standard:

"C716 (R735) If data-target is not unlimited polymorphic, data-pointer-object
shall be type compatible (5.1.1.2) with it, and the corresponding kind type
parameters shall be equal."

The type "character" is doubtlessly compatible with the type "character" and
both kind type parameters are the same (namely "1" = default character). I
cannot find any special case about the LENgth type parameter in that section.

In Fortran 95 I also only read:
"Constraint: The target shall be of the same type, kind type parameters, and
rank as the pointer."

I must miss something because it is extremely unlikely that all compiler get it
wrong.


-- 


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


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

* [Bug fortran/31822] Missing run-time bound checks for character pointer => target
  2007-05-04 19:21 [Bug fortran/31822] New: Missing run-time bound checks for character pointer => target burnus at gcc dot gnu dot org
  2007-08-09 22:52 ` [Bug fortran/31822] " fxcoudert at gcc dot gnu dot org
  2008-12-17  9:48 ` burnus at gcc dot gnu dot org
@ 2008-12-17  9:57 ` burnus at gcc dot gnu dot org
  2008-12-17 10:16 ` domob at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-12-17  9:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2008-12-17 09:56 -------
For Fortran 97 I found it; it is in the first sentence after the "Contrain:"s
"The target shall have the same type parameters as the pointer-object"

For Fortran 2003 I'm still searching (it does not seem to be in the
corrigenda).

OK. Found it. I think the "Otherwise" clause of the following applies:

"If data-target is a disassociated pointer, all nondeferred type parameters of
the declared type of data pointer-object that correspond to nondeferred type
parameters of data-target shall have the same values as the corresponding type
parameters of data-target. Otherwise, all nondeferred type parameters of the
declared type of data-pointer-object shall have the same values as the
corresponding type parameters of data-target."

Thus: One indeed needs the check mentioned in comment 0.


-- 


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


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

* [Bug fortran/31822] Missing run-time bound checks for character pointer => target
  2007-05-04 19:21 [Bug fortran/31822] New: Missing run-time bound checks for character pointer => target burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-12-17  9:57 ` burnus at gcc dot gnu dot org
@ 2008-12-17 10:16 ` domob at gcc dot gnu dot org
  2008-12-18 10:08 ` domob at gcc dot gnu dot org
  2008-12-18 10:14 ` domob at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-12-17 10:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from domob at gcc dot gnu dot org  2008-12-17 10:14 -------
Thanks for the analysis, Tobias, I will then take this on as supplement to PR
38137.


-- 

domob at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |domob at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-08-09 22:52:00         |2008-12-17 10:14:20
               date|                            |


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


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

* [Bug fortran/31822] Missing run-time bound checks for character pointer => target
  2007-05-04 19:21 [Bug fortran/31822] New: Missing run-time bound checks for character pointer => target burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-12-17 10:16 ` domob at gcc dot gnu dot org
@ 2008-12-18 10:08 ` domob at gcc dot gnu dot org
  2008-12-18 10:14 ` domob at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-12-18 10:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from domob at gcc dot gnu dot org  2008-12-18 10:07 -------
Subject: Bug 31822

Author: domob
Date: Thu Dec 18 10:05:54 2008
New Revision: 142808

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142808
Log:
2008-12-18  Daniel Kraft  <d@domob.eu>

        PR fortran/31822
        * gfortran.h (gfc_check_same_strlen): Made public.
        * trans.h (gfc_trans_same_strlen_check): Made public.
        * check.c (gfc_check_same_strlen): Made public and adapted error
        message output to be useful not only for intrinsics.
        (gfc_check_merge): Adapt to gfc_check_same_strlen change.
        * expr.c (gfc_check_pointer_assign): Use gfc_check_same_strlen for
        string length compile-time check.
        * trans-expr.c (gfc_trans_pointer_assignment): Add runtime-check for
        equal string lengths using gfc_trans_same_strlen_check.
        * trans-intrinsic.c (gfc_trans_same_strlen_check): Renamed and made
        public from conv_same_strlen_check.
        (gfc_conv_intrinsic_merge): Adapted accordingly.

2008-12-18  Daniel Kraft  <d@domob.eu>

        PR fortran/31822
        * gfortran.dg/char_pointer_assign_2.f90: Updated expected error message
        to be more detailed.
        * gfortran.dg/char_pointer_assign_4.f90: New test.
        * gfortran.dg/char_pointer_assign_5.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/char_pointer_assign_4.f90
    trunk/gcc/testsuite/gfortran.dg/char_pointer_assign_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/char_pointer_assign_2.f90


-- 


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


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

* [Bug fortran/31822] Missing run-time bound checks for character pointer => target
  2007-05-04 19:21 [Bug fortran/31822] New: Missing run-time bound checks for character pointer => target burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-12-18 10:08 ` domob at gcc dot gnu dot org
@ 2008-12-18 10:14 ` domob at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-12-18 10:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from domob at gcc dot gnu dot org  2008-12-18 10:12 -------
Fixed on trunk/4.4.


-- 

domob at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2008-12-18 10:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-04 19:21 [Bug fortran/31822] New: Missing run-time bound checks for character pointer => target burnus at gcc dot gnu dot org
2007-08-09 22:52 ` [Bug fortran/31822] " fxcoudert at gcc dot gnu dot org
2008-12-17  9:48 ` burnus at gcc dot gnu dot org
2008-12-17  9:57 ` burnus at gcc dot gnu dot org
2008-12-17 10:16 ` domob at gcc dot gnu dot org
2008-12-18 10:08 ` domob at gcc dot gnu dot org
2008-12-18 10:14 ` domob 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).