public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/96896] New: Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function
@ 2020-09-02 10:18 burnus at gcc dot gnu.org
  2020-09-02 10:45 ` [Bug fortran/96896] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-02 10:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96896

            Bug ID: 96896
           Summary: Bogus 'Different ranks in pointer assignment' with
                    'array-variable = scalar' if LHS is a function
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

The following program fails with:
  Error: Different ranks in pointer assignment

Function calls returning a pointer are regarded as variable, hence, the
following boils down to
  array_variable = scalar
which should be fine.

program reshape_test
    implicit none
    real, target, dimension (1:9) :: b
    b = 0.0 ! needed otherwise triggers a FIXME
    myshape(b) = 0.0  ! LHS: 3x3 array, RHS: scalar
contains
  function myshape(b)
    real, target, dimension (1:9) :: b
    real, pointer :: myshape(:,:)
    myshape(1:3,1:3) => b
  end function myshape
end program reshape_test

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

* [Bug fortran/96896] Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function
  2020-09-02 10:18 [Bug fortran/96896] New: Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function burnus at gcc dot gnu.org
@ 2020-09-02 10:45 ` burnus at gcc dot gnu.org
  2020-09-03  7:27 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-02 10:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96896

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The error occurs for the LHS of:
    myshape(b) = 0.0

reshape_test:_F.DA0  =>  myshape[[((reshape_test:b(FULL)))]]

(gfc_debug_expr output)

(gdb) p lvalue->rank 
$9 = 0
(gdb) p rvalue->rank 
$10 = 2

Maybe something like

--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -11598 +11598 @@ resolve_ptr_fcn_assign (gfc_code **code, gfc_namespace *ns)
-  tmp_ptr_expr = get_temp_from_expr ((*code)->expr2, ns);
+  tmp_ptr_expr = get_temp_from_expr ((*code)->expr1, ns);

Or if expr2->rank == 0 and expr1->rank > 0, it has to be updated afterwards. At
the moment, I do not see whether 'expr1' or 'expr2' makes more sense in terms
of polymorphic variables etc.

However, at a glance, expr1 seems to be more sensible...

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

* [Bug fortran/96896] Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function
  2020-09-02 10:18 [Bug fortran/96896] New: Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function burnus at gcc dot gnu.org
  2020-09-02 10:45 ` [Bug fortran/96896] " burnus at gcc dot gnu.org
@ 2020-09-03  7:27 ` burnus at gcc dot gnu.org
  2020-09-07 10:30 ` cvs-commit at gcc dot gnu.org
  2020-09-07 10:32 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-03  7:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96896

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553154.html

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

* [Bug fortran/96896] Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function
  2020-09-02 10:18 [Bug fortran/96896] New: Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function burnus at gcc dot gnu.org
  2020-09-02 10:45 ` [Bug fortran/96896] " burnus at gcc dot gnu.org
  2020-09-03  7:27 ` burnus at gcc dot gnu.org
@ 2020-09-07 10:30 ` cvs-commit at gcc dot gnu.org
  2020-09-07 10:32 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-07 10:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96896

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:2b0df0a6ac79b34f5fac4f3d456e8e14db220e4a

commit r11-3029-g2b0df0a6ac79b34f5fac4f3d456e8e14db220e4a
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Sep 7 12:29:05 2020 +0200

    Fortran: Fixes for pointer function call as variable (PR96896)

    gcc/fortran/ChangeLog:

            PR fortran/96896
            * resolve.c (get_temp_from_expr): Also reset proc_pointer +
            use_assoc attribute.
            (resolve_ptr_fcn_assign): Use information from the LHS.

    gcc/testsuite/ChangeLog:

            PR fortran/96896
            * gfortran.dg/ptr_func_assign_4.f08: Update dg-error.
            * gfortran.dg/ptr-func-3.f90: New test.

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

* [Bug fortran/96896] Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function
  2020-09-02 10:18 [Bug fortran/96896] New: Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-09-07 10:30 ` cvs-commit at gcc dot gnu.org
@ 2020-09-07 10:32 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-07 10:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96896

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

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on GCC 11 mainline.

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

end of thread, other threads:[~2020-09-07 10:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02 10:18 [Bug fortran/96896] New: Bogus 'Different ranks in pointer assignment' with 'array-variable = scalar' if LHS is a function burnus at gcc dot gnu.org
2020-09-02 10:45 ` [Bug fortran/96896] " burnus at gcc dot gnu.org
2020-09-03  7:27 ` burnus at gcc dot gnu.org
2020-09-07 10:30 ` cvs-commit at gcc dot gnu.org
2020-09-07 10:32 ` 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).