Bug 38917 - Can't use DATA to initialize pointer to array to NULL()
Summary: Can't use DATA to initialize pointer to array to NULL()
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-01-19 22:03 UTC by Dick Hendrickson
Modified: 2009-04-06 10:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-01-22 20:16:51


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2009-01-19 22:03:07 UTC
The following program gives error messages for using DATA to iniialize pointers to arrays to NULL()

Dick Hendrickson

      SUBROUTINE PF0005

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

      REAL, SAVE, POINTER :: PTR1
      INTEGER, POINTER       :: PTR2(:,:,:)
      CHARACTER(LEN=1), SAVE, POINTER :: PTR3(:)

      DATA  PTR1 / NULL() /
      DATA  PTR2 / NULL() /
      DATA  PTR3 / NULL() /

      end subroutine pf0005


C:\documents and settings\s and h\my documents\g_experiments\gfortran>gfortran t
ry_pf0005.f
try_pf0005.f:12.10:

      DATA  PTR3 / NULL() /
          1
Error: Nonconstant array section at (1) in DATA statement
try_pf0005.f:11.10:

      DATA  PTR2 / NULL() /
          1
Error: Nonconstant array section at (1) in DATA statement
Comment 1 Tobias Burnus 2009-01-20 07:25:22 UTC
Confirm. Thanks for the report.

R532 data-stmt-constant   is ...
                          or null-init

R507 null-init   is function-reference
C506 (R507) The function-reference shall be a reference to the NULL intrinsic
            function with no arguments

Probably a duplicate of PR 38918.
Comment 2 Paul Thomas 2009-01-22 20:16:51 UTC
I am just about to post a fix.

Paul
Comment 3 Paul Thomas 2009-01-24 12:54:34 UTC
See PR38918 for fix
Comment 4 Paul Thomas 2009-03-31 20:06:08 UTC
Subject: Bug 38917

Author: pault
Date: Tue Mar 31 20:05:44 2009
New Revision: 145371

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

	PR fortran/38917
	* expr.c (gfc_check_assign): Allow pointer components when
	checking for NULL.

	PR fortran/38918
	* resolve.c (check_data_variable): Treat pointer arrays with
	scalars.

2009-03-31  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/38917
	PR fortran/38918
	* gfortran.dg/data_pointer_1.f90: New test.

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

Comment 5 Paul Thomas 2009-04-06 10:54:06 UTC
Fixed on trunk.  I am prepared to backport but the mood appears to be against it.

Thanks for the report.

Paul