public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/25030]  New: Character pointer can associated with not the same length character variable.
@ 2005-11-25  8:55 iguchi at coral dot t dot u-tokyo dot ac dot jp
  2005-11-26  0:48 ` [Bug fortran/25030] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: iguchi at coral dot t dot u-tokyo dot ac dot jp @ 2005-11-25  8:55 UTC (permalink / raw)
  To: gcc-bugs

In the following program, pointer association is not allowd.
But I can compile successfully, and get the output of random character
string whose length is 999.

I think this is wrong behavior.

program char_array_const
  implicit none
  character(len=999), pointer :: p
  character(len=12), target :: string = "test string"

  p => string
  print *, trim(p)
end program


-- 
           Summary: Character pointer can associated with not the same
                    length character variable.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: iguchi at coral dot t dot u-tokyo dot ac dot jp


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


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
@ 2005-11-26  0:48 ` pinskia at gcc dot gnu dot org
  2005-11-26 10:04 ` fxcoudert at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-26  0:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-26 00:48 -------
Hmm, IFC does the same thing as gfortran.


-- 


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


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
  2005-11-26  0:48 ` [Bug fortran/25030] " pinskia at gcc dot gnu dot org
@ 2005-11-26 10:04 ` fxcoudert at gcc dot gnu dot org
  2005-11-26 16:12 ` kargl at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-11-26 10:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2005-11-26 10:04 -------
This was fixed at some point, since current gfortran mainline (4.2) does it the
way you want:

$ gfortran u.f90 && ./a.out 
 test string 

But indeed, Intel output a garbage string, g95 and Sun f90 reject the code. Can
someone confirm that this code is indeed processor-dependent according to the
standard?


-- 


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


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
  2005-11-26  0:48 ` [Bug fortran/25030] " pinskia at gcc dot gnu dot org
  2005-11-26 10:04 ` fxcoudert at gcc dot gnu dot org
@ 2005-11-26 16:12 ` kargl at gcc dot gnu dot org
  2005-12-06  5:32 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2005-11-26 16:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from kargl at gcc dot gnu dot org  2005-11-26 16:12 -------
I believe the code is illegal from 7.5.2, page 110,

   Constraint:  The target shall be of the same type, kind type parameters,
                and rank as the pointer.

Then on page 111, you find "The target shall have the same type parameters
as the pointer-object." 

BTW, both Lahey's web-based checking utility and NAG's compiler
rejects this code.

BTW2, gfortran 4.2 compiles the code, but I get garbage.


-- 

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=25030


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
                   ` (2 preceding siblings ...)
  2005-11-26 16:12 ` kargl at gcc dot gnu dot org
@ 2005-12-06  5:32 ` pault at gcc dot gnu dot org
  2006-01-02  7:19 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2005-12-06  5:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2005-12-06 05:32 -------
(In reply to comment #3)
> I believe the code is illegal from 7.5.2, page 110,
> 
>    Constraint:  The target shall be of the same type, kind type parameters,
>                 and rank as the pointer.
> 
> Then on page 111, you find "The target shall have the same type parameters
> as the pointer-object." 

I believe that you are correct - I worried at this one with PR15809. Automatic
character length pointer dummies are a bit out of frame if this constraint is
asserted.
> 
> BTW, both Lahey's web-based checking utility and NAG's compiler
> rejects this code.

This could easily be done in gfortran.  I will prepare a patch to do it.
> 
> BTW2, gfortran 4.2 compiles the code, but I get garbage.
> 

If you make the pointer very much bigger than the pointee/target, you can
provoke segfaults.

I am working (very slowly) on a patch that would enable pointer aliassing in
gfortran.  This would include aliassing between characters of different sizes. 
This PR flags up:

(i) This will have to subject to -std=gnu
(ii) The size of the elements of the pointer will have to be asserted to be
smaller than that of the pointee/target.
(iii) I will have to be fiendishly clever with warnings, errors and
assertions....

In the mean time, I will ban it all!

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                     |


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


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
                   ` (3 preceding siblings ...)
  2005-12-06  5:32 ` pault at gcc dot gnu dot org
@ 2006-01-02  7:19 ` pinskia at gcc dot gnu dot org
  2006-01-29  6:08 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-02  7:19 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-01-02 07:19:16
               date|                            |


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



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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
                   ` (4 preceding siblings ...)
  2006-01-02  7:19 ` pinskia at gcc dot gnu dot org
@ 2006-01-29  6:08 ` pault at gcc dot gnu dot org
  2006-01-30  5:45 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-01-29  6:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2006-01-29 06:08 -------
Subject: Bug 25030

Author: pault
Date: Sun Jan 29 06:08:07 2006
New Revision: 110365

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

        PR fortran/17911
        * expr.c (gfc_check_assign, gfc_check_pointer_assign): Emit error if
        the lvalue is a use associated procedure.

        PR fortran/20895
        PR fortran/25030
        * expr.c (gfc_check_pointer_assign): Emit error if lvalue and rvalue
        character lengths are not the same.  Use gfc_dep_compare_expr for the
        comparison.
        * gfortran.h: Add prototype for gfc_dep_compare_expr.
        * dependency.h: Remove prototype for gfc_dep_compare_expr.

2006-01-29  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/17911
        * gfortran.dg/procedure_lvalue.f90: New test.

        PR fortran/20895
        PR fortran/25030
        * gfortran.dg/char_pointer_assign_2.f90: New test.
        * gfortran.dg/char_result_1.f90: Correct unequal charlen pointer
        assignment to be consistent with standard.
        * gfortran.dg/char_result_2.f90: The same.
        * gfortran.dg/char_result_8.f90: The same.

Added:
    trunk/gcc/testsuite/gfortran.dg/char_pointer_assign_2.f90
    trunk/gcc/testsuite/gfortran.dg/procedure_lvalue.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/dependency.h
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/char_result_1.f90
    trunk/gcc/testsuite/gfortran.dg/char_result_2.f90
    trunk/gcc/testsuite/gfortran.dg/char_result_8.f90


-- 


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


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
                   ` (5 preceding siblings ...)
  2006-01-29  6:08 ` pault at gcc dot gnu dot org
@ 2006-01-30  5:45 ` pault at gcc dot gnu dot org
  2006-01-30  5:52 ` pault at gcc dot gnu dot org
  2006-01-30 12:38 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-01-30  5:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2006-01-30 05:45 -------
Subject: Bug 25030

Author: pault
Date: Mon Jan 30 05:45:06 2006
New Revision: 110394

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

        PR fortran/18578
        PR fortran/18579
        PR fortran/20857
        PR fortran/20885
        * interface.c (compare_actual_formal): Error for INTENT(OUT or INOUT)
        if actual argument is not a variable.

        PR fortran/17911
        * expr.c (gfc_check_assign, gfc_check_pointer_assign): Emit error if
        the lvalue is a use associated procedure.

        PR fortran/20895
        PR fortran/25030
        * expr.c (gfc_check_pointer_assign): Emit error if lvalue and rvalue
        character lengths are not the same.  Use gfc_dep_compare_expr for the
        comparison.
        * gfortran.h: Add prototype for gfc_dep_compare_expr.
        * dependency.h: Remove prototype for gfc_dep_compare_expr.

2006-01-30  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/18578
        PR fortran/18579
        PR fortran/20857
        PR fortran/20885
        * gfortran.dg/intent_out_1.f90: New test.

        PR fortran/17911
        * gfortran.dg/procedure_lvalue.f90: New test.

        PR fortran/20895
        PR fortran/25030
        * gfortran.dg/char_pointer_assign_2.f90: New test.
        * gfortran.dg/char_result_1.f90: Correct unequal charlen pointer
        assignment to be consistent with standard.
        * gfortran.dg/char_result_2.f90: The same.
        * gfortran.dg/char_result_8.f90: The same.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_pointer_assign_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/intent_out_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/procedure_lvalue.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/dependency.h
    branches/gcc-4_1-branch/gcc/fortran/expr.c
    branches/gcc-4_1-branch/gcc/fortran/gfortran.h
    branches/gcc-4_1-branch/gcc/fortran/interface.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_8.f90


-- 


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


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
                   ` (6 preceding siblings ...)
  2006-01-30  5:45 ` pault at gcc dot gnu dot org
@ 2006-01-30  5:52 ` pault at gcc dot gnu dot org
  2006-01-30 12:38 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-01-30  5:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pault at gcc dot gnu dot org  2006-01-30 05:52 -------
Fixed on trunk and 4.1.

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=25030


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

* [Bug fortran/25030] Character pointer can associated with not the same length character variable.
  2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
                   ` (7 preceding siblings ...)
  2006-01-30  5:52 ` pault at gcc dot gnu dot org
@ 2006-01-30 12:38 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-30 12:38 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.0


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


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

end of thread, other threads:[~2006-01-30 12:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-25  8:55 [Bug fortran/25030] New: Character pointer can associated with not the same length character variable iguchi at coral dot t dot u-tokyo dot ac dot jp
2005-11-26  0:48 ` [Bug fortran/25030] " pinskia at gcc dot gnu dot org
2005-11-26 10:04 ` fxcoudert at gcc dot gnu dot org
2005-11-26 16:12 ` kargl at gcc dot gnu dot org
2005-12-06  5:32 ` pault at gcc dot gnu dot org
2006-01-02  7:19 ` pinskia at gcc dot gnu dot org
2006-01-29  6:08 ` pault at gcc dot gnu dot org
2006-01-30  5:45 ` pault at gcc dot gnu dot org
2006-01-30  5:52 ` pault at gcc dot gnu dot org
2006-01-30 12:38 ` pinskia 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).