public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure.
@ 2007-04-18 12:37 David at ham dot dropbear dot id dot au
2007-04-18 13:09 ` [Bug fortran/31620] [regression 4.3] " dfranke at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: David at ham dot dropbear dot id dot au @ 2007-04-18 12:37 UTC (permalink / raw)
To: gcc-bugs
If an array of a derived type is declared and one component is set to zero then
all the components are set to zero. The following program illustrates the
problem:
program test_assign
type my_type
integer :: a
integer :: b
end type my_type
type(my_type), dimension(1) :: mine
mine%b=4
print *, "Should be 4: ", mine%b
mine%a=1
print *, "Should be 4: ", mine%b
mine%a=0
print *, "Should be 4: ", mine%b
print *, "Should be 0: ", mine%a
end program test_assign
The output of this is:
Should be 4: 4
Should be 4: 4
Should be 4: 0
Should be 0: 0
Note the third line.
--
Summary: Zeroing one component of array of derived types zeros
the whole structure.
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: David at ham dot dropbear dot id dot au
GCC build triplet: RHEL4 x86_64
GCC host triplet: RHEL4 x86_64
GCC target triplet: RHEL4 x86_64
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [regression 4.3] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
@ 2007-04-18 13:09 ` dfranke at gcc dot gnu dot org
2007-04-18 13:25 ` dfranke at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-04-18 13:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from dfranke at gcc dot gnu dot org 2007-04-18 14:09 -------
Strange, indeed.
Can confirm this behaviour for 4.3 (20070417), neither 4.1.1 nor 4.2 (20070417)
exhibit the problem.
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dfranke at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Known to fail| |4.3.0
Known to work| |4.1.1 4.2.0
Last reconfirmed|0000-00-00 00:00:00 |2007-04-18 14:09:12
date| |
Summary|Zeroing one component of |[regression 4.3] Zeroing one
|array of derived types zeros|component of array of
|the whole structure. |derived types zeros the
| |whole structure.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [regression 4.3] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
2007-04-18 13:09 ` [Bug fortran/31620] [regression 4.3] " dfranke at gcc dot gnu dot org
@ 2007-04-18 13:25 ` dfranke at gcc dot gnu dot org
2007-04-21 22:37 ` [Bug fortran/31620] [4.3 regression] " pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-04-18 13:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from dfranke at gcc dot gnu dot org 2007-04-18 14:25 -------
$> cat pr31620.f90
program test_assign
type my_type
integer :: a
integer :: b
end type my_type
type(my_type), dimension(1) :: mine ! note that MINE is an array
mine%b=4
mine%a=1
print *, mine
mine%a=0
print *, mine
end program test_assign
$> gfortran-svn -g -fdump-tree-original pr31620.f90
The dump shows between the print statements:
[...]
(void) __builtin_memset ((void *) &mine, 0, 8);
[...]
which obviously is the culprit.
Adding Roger Sayle as CC as he worked on this a while ago.
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |roger at eyesopen dot com
Keywords| |wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
2007-04-18 13:09 ` [Bug fortran/31620] [regression 4.3] " dfranke at gcc dot gnu dot org
2007-04-18 13:25 ` dfranke at gcc dot gnu dot org
@ 2007-04-21 22:37 ` pinskia at gcc dot gnu dot org
2007-04-21 22:51 ` kargl at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-21 22:37 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
GCC build triplet|RHEL4 x86_64 |
GCC host triplet|RHEL4 x86_64 |
GCC target triplet|RHEL4 x86_64 |
Summary|[regression 4.3] Zeroing one|[4.3 regression] Zeroing one
|component of array of |component of array of
|derived types zeros the |derived types zeros the
|whole structure. |whole structure.
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (2 preceding siblings ...)
2007-04-21 22:37 ` [Bug fortran/31620] [4.3 regression] " pinskia at gcc dot gnu dot org
@ 2007-04-21 22:51 ` kargl at gcc dot gnu dot org
2007-04-21 22:56 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-04-21 22:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from kargl at gcc dot gnu dot org 2007-04-21 23:51 -------
The OP doesn't understand his own program.
Closing as invalid.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu dot org
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (3 preceding siblings ...)
2007-04-21 22:51 ` kargl at gcc dot gnu dot org
@ 2007-04-21 22:56 ` pinskia at gcc dot gnu dot org
2007-04-21 23:10 ` kargl at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-21 22:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2007-04-21 23:56 -------
(In reply to comment #3)
> The OP doesn't understand his own program.
Huh? (or did you close the wrong bug report?)
Here is a simplified testcase that does not call print:
program test_assign
type my_type
integer :: a
integer :: b
end type my_type
type(my_type), dimension(1) :: mine ! note that MINE is an array
mine%b=4
mine%a=1
mine%a=0
if (any (mine%b .ne. 4)) call abort ()
end program test_assign
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (4 preceding siblings ...)
2007-04-21 22:56 ` pinskia at gcc dot gnu dot org
@ 2007-04-21 23:10 ` kargl at gcc dot gnu dot org
2007-04-22 21:05 ` pault at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-04-21 23:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from kargl at gcc dot gnu dot org 2007-04-22 00:10 -------
(In reply to comment #4)
> (In reply to comment #3)
> > The OP doesn't understand his own program.
> Huh? (or did you close the wrong bug report?)
> Here is a simplified testcase that does not call print:
> program test_assign
Sorry, David, I may have read the program too quick.
Two hours of umping behind the plate, followed by
1.5 hours of soccer, led to a rash decision.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (6 preceding siblings ...)
2007-04-22 21:05 ` pault at gcc dot gnu dot org
@ 2007-04-22 21:05 ` patchapp at dberlin dot org
2007-04-23 15:14 ` pault at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: patchapp at dberlin dot org @ 2007-04-22 21:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from patchapp at dberlin dot org 2007-04-22 22:05 -------
Subject: Bug number PR31620
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-04/msg01431.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (5 preceding siblings ...)
2007-04-21 23:10 ` kargl at gcc dot gnu dot org
@ 2007-04-22 21:05 ` pault at gcc dot gnu dot org
2007-04-22 21:05 ` patchapp at dberlin dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-04-22 21:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2007-04-22 22:05 -------
I just posted a patch.
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 |
Status|REOPENED |ASSIGNED
Last reconfirmed|2007-04-18 14:09:12 |2007-04-22 22:05:46
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (7 preceding siblings ...)
2007-04-22 21:05 ` patchapp at dberlin dot org
@ 2007-04-23 15:14 ` pault at gcc dot gnu dot org
2007-04-23 16:52 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-04-23 15:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pault at gcc dot gnu dot org 2007-04-23 16:14 -------
Subject: Bug 31620
Author: pault
Date: Mon Apr 23 16:13:48 2007
New Revision: 124069
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124069
Log:
2007-04-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31630
* resolve.c (resolve_symbol): Allow resolution of formal
namespaces nested within formal namespaces coming from modules.
PR fortran/31620
* trans-expr.c (gfc_trans_assignment): Make the call to
gfc_trans_zero_assign conditional on the lhs array ref being
the only reference.
2007-04-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31630
* gfortran.dg/used_types_17.f90: New test.
PR fortran/31620
* gfortran.dg/zero_array_components_1.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/used_types_17.f90
trunk/gcc/testsuite/gfortran.dg/zero_array_components_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (8 preceding siblings ...)
2007-04-23 15:14 ` pault at gcc dot gnu dot org
@ 2007-04-23 16:52 ` pault at gcc dot gnu dot org
2007-04-23 19:55 ` roger at eyesopen dot com
2007-04-23 20:06 ` roger at eyesopen dot com
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-04-23 16:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pault at gcc dot gnu dot org 2007-04-23 17:52 -------
Fixed on trunk
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=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (9 preceding siblings ...)
2007-04-23 16:52 ` pault at gcc dot gnu dot org
@ 2007-04-23 19:55 ` roger at eyesopen dot com
2007-04-23 20:06 ` roger at eyesopen dot com
11 siblings, 0 replies; 13+ messages in thread
From: roger at eyesopen dot com @ 2007-04-23 19:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from roger at eyesopen dot com 2007-04-23 20:54 -------
Many thanks to Paul for fixing this, and my apologies for being overloaded at
work and not being available to investigate it fully myself.
I believe that Paul's fix of explicitly checking expr1->ref->next is the
correct way to determine whether a reference is too complex. My confusion is
that this test should already be being checked/verified in the call to
gfc_full_array_ref_p on the line immediately following his change.
So on line 1124 of dependency.c in gfc_f_a_r_p is the clause
if (ref->next)
return false;
which should be doing exactly the same thing. The reason I mention this
is perhaps GCC is miscompiling itself, and this gfortran failure is the visible
manifestation. Alternatively, perhaps ref->next isn't getting set properly,
or is getting clobbered somehow.
Paul does your new testcase fail without your fix?
My apologies again if I'm missing something obvious.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/31620] [4.3 regression] Zeroing one component of array of derived types zeros the whole structure.
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
` (10 preceding siblings ...)
2007-04-23 19:55 ` roger at eyesopen dot com
@ 2007-04-23 20:06 ` roger at eyesopen dot com
11 siblings, 0 replies; 13+ messages in thread
From: roger at eyesopen dot com @ 2007-04-23 20:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from roger at eyesopen dot com 2007-04-23 21:05 -------
Duh! I am missing something obvious! The ref->u.ar.type == AR_FULL test on
line 1120 returns true. The test for ref->next needs to be moved earlier.
Sorry again for the inconvenience. Clearly, my brain isn't working properly at
the moment :-(
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31620
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-04-23 20:06 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-18 12:37 [Bug fortran/31620] New: Zeroing one component of array of derived types zeros the whole structure David at ham dot dropbear dot id dot au
2007-04-18 13:09 ` [Bug fortran/31620] [regression 4.3] " dfranke at gcc dot gnu dot org
2007-04-18 13:25 ` dfranke at gcc dot gnu dot org
2007-04-21 22:37 ` [Bug fortran/31620] [4.3 regression] " pinskia at gcc dot gnu dot org
2007-04-21 22:51 ` kargl at gcc dot gnu dot org
2007-04-21 22:56 ` pinskia at gcc dot gnu dot org
2007-04-21 23:10 ` kargl at gcc dot gnu dot org
2007-04-22 21:05 ` pault at gcc dot gnu dot org
2007-04-22 21:05 ` patchapp at dberlin dot org
2007-04-23 15:14 ` pault at gcc dot gnu dot org
2007-04-23 16:52 ` pault at gcc dot gnu dot org
2007-04-23 19:55 ` roger at eyesopen dot com
2007-04-23 20:06 ` roger at eyesopen dot com
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).