RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1134560 - Component declarations overwrite types of Cray Pointee variables
Summary: Component declarations overwrite types of Cray Pointee variables
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.4
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: Miroslav Franc
URL: https://gcc.gnu.org/bugzilla/show_bug...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-27 19:07 UTC by Fritz Reese
Modified: 2016-02-01 02:29 UTC (History)
6 users (show)

Fixed In Version: gcc-4.4.7-12.el6
Doc Type: Bug Fix
Doc Text:
In previous versions of the GNU Fortran compiler, the type specifiers for Cray pointees were incorrectly overwritten by the type specifiers of components with the same name. Consequently, compiling failed with an error message. This bug has been fixed, and the Cray pointers are now handled correctly.
Clone Of:
Environment:
Last Closed: 2015-07-22 06:48:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch and testcase (1.26 KB, patch)
2014-08-27 19:13 UTC, Fritz Reese
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 62174 0 None None None Never
Red Hat Product Errata RHBA-2015:1339 0 normal SHIPPED_LIVE gcc bug fix and enhancement update 2015-07-20 18:00:00 UTC

Description Fritz Reese 2014-08-27 19:07:49 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0
Build Identifier: 

The typespecs for Cray pointees are overwritten by the typespecs of components with the same name which are declared later. The problem is present as far as I can tell from gcc-4.1.0 all the way up through gcc-4.8.3.

Reproducible: Always

Steps to Reproduce:
Example:

type t1
  integer i
end type t1
type(t1) x

pointer (x_ptr, x)

type t2
  real x ! this declaration overwrites x's type
end type t2

x%i = 0 ! this causes an error; the compiler thinks x is a real

end
Actual Results:  
Running gfortran-4.4.7 shipped with RH6.4:

$ gfortran test.f90
test.f90:12.2:

x%i = 0 ! this causes an error; the compiler thinks x is a real
  1
Error: Unexpected '%' for nonderived-type variable 'x' at (1)


Expected Results:  
There should be no compile errors.

Submitted the bug report to GNU (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62174) but have not heard back. I have a patch which I will attach.

Comment 2 Fritz Reese 2014-08-27 19:13:52 UTC
Created attachment 931658 [details]
Patch and testcase

Here is a proposed patch and testcase. When variable_decl() finds a declaration which shares a name with a Cray pointee, it should not care if the declaration is actually a component declaration.

2014-08-18  Fritz Reese  <Reese-Fritz>

	* decl.c (variable_decl): Don't overwrite typespecs of Cray pointees
	when matching a component declaration.


diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 4048ac9..7b3c59a 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1904,8 +1904,9 @@ variable_decl (int elem)
     }
 
   /*  If this symbol has already shown up in a Cray Pointer declaration,
+      and this is not a component declaration,
       then we want to set the type & bail out.  */
-  if (gfc_option.flag_cray_pointer)
+  if (gfc_option.flag_cray_pointer && gfc_current_state () != COMP_DERIVED)
     {
       gfc_find_symbol (name, gfc_current_ns, 1, &sym);
       if (sym != NULL && sym->attr.cray_pointee)
diff --git a/gcc/testsuite/gfortran.dg/cray_pointers_10.f90 b/gcc/testsuite/gfortran.dg/cray_pointers_10.f90
new file mode 100644
index 0000000..fcc0132
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/cray_pointers_10.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-fcray-pointer" }
+!
+! Since the introduction of Cray pointers in 4.1.0 as late as 4.8.3,
+! component declarations within derived types would overwrite the typespec of 
+! variables with the same name who were Cray pointees.
+implicit none
+
+type t1
+  integer i
+end type t1
+type(t1) x
+
+pointer (x_ptr, x)
+
+type t2
+  real x ! should not overwrite x's type
+end type t2
+
+x%i = 0 ! should see no error here
+
+end

Comment 9 errata-xmlrpc 2015-07-22 06:48:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1339.html


Note You need to log in before you can comment on or make changes to this bug.