Bug 20895

Summary: All type parameters shall be identical in a POINTER assignment
Product: gcc Reporter: Joost VandeVondele <Joost.VandeVondele>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, tobi
Priority: P2 Keywords: accepts-invalid
Version: 4.1.0   
Target Milestone: 4.1.0   
Host: Target: i686-pc-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed: 2006-01-08 06:11:54
Bug Depends on:    
Bug Blocks: 19276    

Description Joost VandeVondele 2005-04-08 16:04:27 UTC
The following is non-standard and the compiler should probably generate a
warning/error with '-pedantic -std=f95'

  CHARACTER(LEN=10), TARGET :: a
  CHARACTER(LEN=4), POINTER :: b
  b=>a
  END
Comment 1 Tobias Schlüter 2005-05-19 17:23:32 UTC
I don't think so, I'm sure this code is valid, but I believe you know the
standard well enough to justify your statement.
Comment 2 Francois-Xavier Coudert 2005-06-25 18:44:41 UTC
Well, don't know the standard reference, but the Sun compiler does error out on
this code.
Comment 3 Andrew Pinski 2005-09-30 20:52:41 UTC
I am going to go out on a limb and say this is invalid so confirmed.
Comment 4 Tobias Schlüter 2005-09-30 21:07:05 UTC
Length is a type parameter.  All type parameters shall be identical in a POINTER
assignment. Hence the example is illegal.

This means that bound checking should reject the following for i /= 5:
  character*5, pointer :: p
  character*10, target :: t

  p => t(1:i)
Comment 5 Paul Thomas 2006-01-29 06:08:12 UTC
Subject: Bug 20895

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

Comment 6 Paul Thomas 2006-01-30 05:45:18 UTC
Subject: Bug 20895

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

Comment 7 Paul Thomas 2006-01-30 05:51:46 UTC
Fixed on trunk and 4.1.

Paul