public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
@ 2012-10-19 20:34 burnus at gcc dot gnu.org
  2012-10-19 21:23 ` [Bug fortran/54992] [4.8 Regression] " janus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-10-19 20:34 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54992
           Summary: [OOP] Wrong offset in the array offset calculation
                    when using nonclass%class(index)%nonclass
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org, pault@gcc.gnu.org


As reported by Andrew Benson in the thread starting at
http://gcc.gnu.org/ml/fortran/2012-10/msg00087.html

The problem is that gfortran generates the wrong code for:

    targetNode%cBh(2)%hostNode => targetNode

where "cBh" is a polymorphic array. The offset is calculated as

  ((base_type *)targetNode->_data->cBh->_data)[ index ].host


Instead of the proper:

  targetNode->_data->cBh->_data.data
               + (index * targetNode->_data->cBh->_vptr_size)


Test case:  http://gcc.gnu.org/ml/fortran/2012-10/msg00100.html

Analysis:   http://gcc.gnu.org/ml/fortran/2012-10/msg00101.html


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

* [Bug fortran/54992] [4.8 Regression] [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
  2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
@ 2012-10-19 21:23 ` janus at gcc dot gnu.org
  2012-10-19 21:37 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2012-10-19 21:23 UTC (permalink / raw)
  To: gcc-bugs


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-10-19
            Summary|[OOP] Wrong offset in the   |[4.8 Regression] [OOP]
                   |array offset calculation    |Wrong offset in the array
                   |when using                  |offset calculation when
                   |nonclass%class(index)%noncl |using
                   |ass                         |nonclass%class(index)%noncl
                   |                            |ass
     Ever Confirmed|0                           |1

--- Comment #1 from janus at gcc dot gnu.org 2012-10-19 21:23:36 UTC ---
(In reply to comment #0)
> Test case:  http://gcc.gnu.org/ml/fortran/2012-10/msg00100.html

Note: While this test case fails with trunk, it seems to work with 4.7.


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

* [Bug fortran/54992] [4.8 Regression] [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
  2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
  2012-10-19 21:23 ` [Bug fortran/54992] [4.8 Regression] " janus at gcc dot gnu.org
@ 2012-10-19 21:37 ` dominiq at lps dot ens.fr
  2012-10-25 11:36 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2012-10-19 21:37 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-10-19 21:37:08 UTC ---
Revision 187190 is OK, revision 187198 is not -> likely r187192.


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

* [Bug fortran/54992] [4.8 Regression] [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
  2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
  2012-10-19 21:23 ` [Bug fortran/54992] [4.8 Regression] " janus at gcc dot gnu.org
  2012-10-19 21:37 ` dominiq at lps dot ens.fr
@ 2012-10-25 11:36 ` janus at gcc dot gnu.org
  2012-11-07 10:03 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2012-10-25 11:36 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from janus at gcc dot gnu.org 2012-10-25 11:36:00 UTC ---
Related (or duplicate): PR 55057.


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

* [Bug fortran/54992] [4.8 Regression] [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
  2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-10-25 11:36 ` janus at gcc dot gnu.org
@ 2012-11-07 10:03 ` jakub at gcc dot gnu.org
  2012-12-26 17:56 ` pault at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-11-07 10:03 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.8.0


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

* [Bug fortran/54992] [4.8 Regression] [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
  2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-11-07 10:03 ` jakub at gcc dot gnu.org
@ 2012-12-26 17:56 ` pault at gcc dot gnu.org
  2013-01-07  9:05 ` pault at gcc dot gnu.org
  2013-01-07 19:11 ` pault at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2012-12-26 17:56 UTC (permalink / raw)
  To: gcc-bugs


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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot       |pault at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> 2012-12-26 17:56:31 UTC ---
This is another result of the underlying bug unearthed in PR54990.

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c    (revision 194721)
--- gcc/fortran/trans-array.c    (working copy)
*************** static tree
*** 3099,3112 ****
  build_array_ref (tree desc, tree offset, tree decl)
  {
    tree tmp;

    /* Class array references need special treatment because the assigned
       type size needs to be used to point to the element.  */ 
    if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))
      && TREE_CODE (desc) == COMPONENT_REF
!     && GFC_CLASS_TYPE_P (TREE_TYPE (TREE_OPERAND (desc, 0))))
      {
!       tree type = gfc_get_element_type (TREE_TYPE (desc));
        tmp = TREE_OPERAND (desc, 0);
        tmp = gfc_get_class_array_ref (offset, tmp);
        tmp = fold_convert (build_pointer_type (type), tmp);
--- 3099,3118 ----
  build_array_ref (tree desc, tree offset, tree decl)
  {
    tree tmp;
+   tree type;
+ 
+   type = TREE_TYPE (TREE_OPERAND (desc, 0));
+   if (TYPE_CANONICAL (type)
+       && GFC_CLASS_TYPE_P (TYPE_CANONICAL (type)))
+     type = TYPE_CANONICAL (type);

    /* Class array references need special treatment because the assigned
       type size needs to be used to point to the element.  */ 
    if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))
      && TREE_CODE (desc) == COMPONENT_REF
!     && GFC_CLASS_TYPE_P (type))
      {
!       type = gfc_get_element_type (TREE_TYPE (desc));
        tmp = TREE_OPERAND (desc, 0);
        tmp = gfc_get_class_array_ref (offset, tmp);
        tmp = fold_convert (build_pointer_type (type), tmp);

fixes it.  As remarked in PR54990, I do not know why this regression has
occurred.  Evidently, GFC_CLASS_TYPE_P is not being transferred from the
canonical type, whereas this was happening before the regression (or a new type
was not being generated?).  I will investigate more.

I have taken this PR.

Cheers

Paul


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

* [Bug fortran/54992] [4.8 Regression] [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
  2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-12-26 17:56 ` pault at gcc dot gnu.org
@ 2013-01-07  9:05 ` pault at gcc dot gnu.org
  2013-01-07 19:11 ` pault at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2013-01-07  9:05 UTC (permalink / raw)
  To: gcc-bugs


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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> 2013-01-07 09:05:10 UTC ---
Fixed by http://gcc.gnu.org/viewcvs?view=revision&revision=194953

It did not register here because I screwed up on the ChangeLog Format (I really
am rusty  :-) ).  I'll fix this tonight.

Thanks for the report.

Paul


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

* [Bug fortran/54992] [4.8 Regression] [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass
  2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-01-07  9:05 ` pault at gcc dot gnu.org
@ 2013-01-07 19:11 ` pault at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2013-01-07 19:11 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> 2013-01-07 19:10:40 UTC ---
Author: pault
Date: Mon Jan  7 19:10:32 2013
New Revision: 194994

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

    PR fortran/53876
    PR fortran/54990
    PR fortran/54992
    * ChangeLog: Correct format error in revision 194953

2013-01-07  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/53876
    PR fortran/54990
    PR fortran/54992
    * ChangeLog: Correct format error in revision 194953

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2013-01-07 19:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19 20:34 [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass burnus at gcc dot gnu.org
2012-10-19 21:23 ` [Bug fortran/54992] [4.8 Regression] " janus at gcc dot gnu.org
2012-10-19 21:37 ` dominiq at lps dot ens.fr
2012-10-25 11:36 ` janus at gcc dot gnu.org
2012-11-07 10:03 ` jakub at gcc dot gnu.org
2012-12-26 17:56 ` pault at gcc dot gnu.org
2013-01-07  9:05 ` pault at gcc dot gnu.org
2013-01-07 19:11 ` pault at gcc dot gnu.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).