public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
@ 2012-04-04 13:17 burnus at gcc dot gnu.org
  2012-04-04 13:19 ` [Bug fortran/52864] " burnus at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-04 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52864
           Summary: [4.6/4.7/4.8 Regression] Assignment to pointer
                    component for INTENT(IN) dummy argument
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


Reported by Vladimír at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/0869abb167bf5680

The following program is rejected since GCC 4.6; it is related to PR 50684 but
not fixed by that patch.

The following program is rejected with:

Error: Dummy argument 'd' with INTENT(IN) in variable definition
       context (assignment) at (1)


     program test
        type PoisFFT_Solver3D
          complex, dimension(:,:,:),&!contiguous,
                          pointer :: work => null()
        end type PoisFFT_Solver3D
     contains
     subroutine PoisFFT_Solver3D_FullPeriodic(D, Phi, RHS)
       type(PoisFFT_Solver3D), intent(in) :: D
       D%work(i,j,k) = 0.0
     end subroutine
     end


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
@ 2012-04-04 13:19 ` burnus at gcc dot gnu.org
  2012-04-04 14:23 ` burnus at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-04 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org
      Known to work|                            |4.1.2, 4.4.6, 4.5.3
   Target Milestone|---                         |4.6.4
      Known to fail|                            |4.6.1, 4.6.3, 4.7.0, 4.8.0


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
  2012-04-04 13:19 ` [Bug fortran/52864] " burnus at gcc dot gnu.org
@ 2012-04-04 14:23 ` burnus at gcc dot gnu.org
  2012-04-11 22:46 ` nnc at lanl dot gov
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-04 14:23 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-04-04
     Ever Confirmed|0                           |1

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-04 14:23:09 UTC ---
Interesting issue. The problem is that
  ptr = <value>
is valid while
  nonptr = <value>
is not. That was checked via "is_pointer". However, "ptr(1,1)" has is_pointer
== false (which is correct).

On the other hand, "check_intentin" handles both pointer assignments and normal
assignment. While for pointers:
  ptr%ptr => null()
is valid, the following isn't
  ptr => null()
By contrast,
  val = value
  val%val = value
are valid.

Solution: Set check_intentin differently for assignments than for pointer
assignments.

Draft patch.

--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4654,11 +4654,15 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer,
bool alloc_obj,
   for (ref = e->ref; ref && check_intentin; ref = ref->next)
     {
       if (ptr_component && ref->type == REF_COMPONENT)
        check_intentin = false;
       if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer)
-       ptr_component = true;
+       {
+         ptr_component = true;
+         if (!pointer)
+           check_intentin = false;
+       }
     }
   if (check_intentin && sym->attr.intent == INTENT_IN)
     {
       if (pointer && is_pointer)
        {


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
  2012-04-04 13:19 ` [Bug fortran/52864] " burnus at gcc dot gnu.org
  2012-04-04 14:23 ` burnus at gcc dot gnu.org
@ 2012-04-11 22:46 ` nnc at lanl dot gov
  2012-04-12  9:52 ` burnus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: nnc at lanl dot gov @ 2012-04-11 22:46 UTC (permalink / raw)
  To: gcc-bugs

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

Neil Carlson <nnc at lanl dot gov> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nnc at lanl dot gov

--- Comment #2 from Neil Carlson <nnc at lanl dot gov> 2012-04-11 22:45:36 UTC ---
Here's a somewhat different example, but I think it exposes the same underlying
bug.  Here's the error message:

    call bar (a%ptr)
              1
Error: Procedure argument at (1) is INTENT(IN) while interface specifies
INTENT(INOUT)

For pointer components of an argument, intent applies to the pointer itself
(i.e., changes in its association status) and NOT the target of the pointer.
This is a fundamental defect in the compiler.

module modA
  type :: typeA
    integer, pointer :: ptr
  end type
contains
  subroutine foo (a)
    type(typeA), intent(in) :: a
    call bar (a%ptr)
  end subroutine
  subroutine bar (n)
    integer, intent(inout) :: n
  end subroutine
end module


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-04-11 22:46 ` nnc at lanl dot gov
@ 2012-04-12  9:52 ` burnus at gcc dot gnu.org
  2012-04-13 13:15 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-12  9:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-12 09:52:03 UTC ---
Regarding the original issue (comment 0): The patch has been submitted to
http://gcc.gnu.org/ml/fortran/2012-04/msg00058.html

 * * *

(In reply to comment #2)
> Here's a somewhat different example, but I think it exposes the same
> underlying bug.

Thanks for the bug report!

While the bug is language wise related, it is rather different in terms of the
compiler: It's not a regression and the bug is in a completely different file.

Untested draft patch:

--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2807,3 +2823,6 @@ compare_parameter_intent (gfc_symbol *formal, gfc_expr
 {
-  if (actual->symtree->n.sym->attr.pointer && !formal->attr.pointer)
+  if (gfc_expr_attr (actual).pointer
+      && ((formal->ts.type == BT_CLASS && formal->attr.class_ok
+          && !CLASS_DATA (formal)->attr.class_pointer)
+         || (formal->ts.type != BT_CLASS && !formal->attr.pointer)))
     return 1;


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-04-12  9:52 ` burnus at gcc dot gnu.org
@ 2012-04-13 13:15 ` rguenth at gcc dot gnu.org
  2012-04-16 21:48 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-04-13 13:15 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-04-13 13:15 ` rguenth at gcc dot gnu.org
@ 2012-04-16 21:48 ` burnus at gcc dot gnu.org
  2012-05-02 12:52 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-16 21:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-16 21:47:39 UTC ---
Author: burnus
Date: Mon Apr 16 21:47:35 2012
New Revision: 186507

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186507
Log:
2012-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * expr.c (gfc_check_vardef_context): Fix assignment check for
        pointer components.

2012-04-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * gfortran.dg/pointer_intent_6.f90: New.


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


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2012-04-16 21:48 ` burnus at gcc dot gnu.org
@ 2012-05-02 12:52 ` burnus at gcc dot gnu.org
  2012-05-02 12:53 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-02 12:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-02 12:51:55 UTC ---
Author: burnus
Date: Wed May  2 12:51:49 2012
New Revision: 187044

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187044
Log:
2012-05-02  Tobias Burnus  <burnus@net-b.de>

        Backport from mainline
        2012-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * expr.c (gfc_check_vardef_context): Fix assignment check for
        pointer components.

2012-05-02  Tobias Burnus  <burnus@net-b.de>

        Backport from mainline
        2012-04-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * gfortran.dg/pointer_intent_6.f90: New.


Added:
    branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/pointer_intent_6.f90
Modified:
    branches/gcc-4_7-branch/gcc/fortran/ChangeLog
    branches/gcc-4_7-branch/gcc/fortran/expr.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2012-05-02 12:52 ` burnus at gcc dot gnu.org
@ 2012-05-02 12:53 ` burnus at gcc dot gnu.org
  2012-05-03  7:19 ` burnus at gcc dot gnu.org
  2012-05-03  7:41 ` burnus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-02 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-02 12:53:24 UTC ---
Author: burnus
Date: Wed May  2 12:53:20 2012
New Revision: 187046

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187046
Log:
2012-05-02  Tobias Burnus  <burnus@net-b.de>

        Backport from mainline
        2012-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * expr.c (gfc_check_vardef_context): Fix assignment check for
        pointer components.

2012-05-02  Tobias Burnus  <burnus@net-b.de>

        Backport from mainline
        2012-04-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * gfortran.dg/pointer_intent_6.f90: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/pointer_intent_6.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/expr.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2012-05-02 12:53 ` burnus at gcc dot gnu.org
@ 2012-05-03  7:19 ` burnus at gcc dot gnu.org
  2012-05-03  7:41 ` burnus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-03  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-03 07:19:08 UTC ---
Author: burnus
Date: Thu May  3 07:18:56 2012
New Revision: 187076

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187076
Log:
2012-05-03  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * interface.c (compare_parameter_intent): Remove.
        (check_intents): Remove call, handle CLASS pointer.
        (compare_actual_formal): Handle CLASS pointer.

2012-05-03  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52864
        * gfortran.dg/pointer_intent_7.f90: New.
        * gfortran.dg/pure_formal_3.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/pointer_intent_7.f90
    trunk/gcc/testsuite/gfortran.dg/pure_formal_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
  2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2012-05-03  7:19 ` burnus at gcc dot gnu.org
@ 2012-05-03  7:41 ` burnus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-03  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-03 07:41:00 UTC ---
FIXED.

The regression of comment 0 by Vladimír has been solved for the trunk (4.8) and
the 4.7/4.6 branches.

The nonregression of comment 2 by Neil has been solved for the trunk (4.8).

Thanks for the bug reports!


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

end of thread, other threads:[~2012-05-03  7:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-04 13:17 [Bug fortran/52864] New: [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument burnus at gcc dot gnu.org
2012-04-04 13:19 ` [Bug fortran/52864] " burnus at gcc dot gnu.org
2012-04-04 14:23 ` burnus at gcc dot gnu.org
2012-04-11 22:46 ` nnc at lanl dot gov
2012-04-12  9:52 ` burnus at gcc dot gnu.org
2012-04-13 13:15 ` rguenth at gcc dot gnu.org
2012-04-16 21:48 ` burnus at gcc dot gnu.org
2012-05-02 12:52 ` burnus at gcc dot gnu.org
2012-05-02 12:53 ` burnus at gcc dot gnu.org
2012-05-03  7:19 ` burnus at gcc dot gnu.org
2012-05-03  7:41 ` burnus 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).