public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments
@ 2014-06-25 22:48 thatcadguy at gmail dot com
  2014-06-27 14:47 ` [Bug fortran/61615] " thatcadguy at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: thatcadguy at gmail dot com @ 2014-06-25 22:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61615
           Summary: Failure to resolve correct generic with TYPE(C_PTR)
                    arguments
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thatcadguy at gmail dot com

The following program does not produce the expected output (the line 'CALL
bar(a, b)' does not choose the subroutine bar_s as it should, it chooses
bar_a1d):

MODULE foo
  USE iso_c_binding
  IMPLICIT NONE
  INTERFACE bar
    MODULE PROCEDURE bar_s
    MODULE PROCEDURE bar_a1d
  END INTERFACE bar
CONTAINS
  SUBROUTINE bar_s(a, b)
    TYPE(c_ptr) :: a, b
    WRITE (0, *) 'in bar_s'
  END SUBROUTINE bar_s

  SUBROUTINE bar_a1d(a, b)
    TYPE(c_ptr) :: a(:), b(:)
    WRITE (0, *) 'in bar_a1d'
  END SUBROUTINE bar_a1d
END MODULE foo

PROGRAM cptr_array_vs_scalar_arg
  USE foo
  USE iso_c_binding
  IMPLICIT NONE
  INTEGER, TARGET :: i
  TYPE(c_ptr) :: a, b
  a = C_LOC(i)
  b = C_LOC(i)
  CALL bar(a, b)
END PROGRAM cptr_array_vs_scalar_arg


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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
@ 2014-06-27 14:47 ` thatcadguy at gmail dot com
  2014-07-12 22:19 ` dominiq at lps dot ens.fr
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: thatcadguy at gmail dot com @ 2014-06-27 14:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jacob Abel <thatcadguy at gmail dot com> ---
I was also told the following incorrect behavior is present from 4.8.1 and on.
I've tested with 4.8.1 and 4.8.2 and received the same behavior.


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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
  2014-06-27 14:47 ` [Bug fortran/61615] " thatcadguy at gmail dot com
@ 2014-07-12 22:19 ` dominiq at lps dot ens.fr
  2014-07-13 15:09 ` dominiq at lps dot ens.fr
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-12 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-07-12
     Ever confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
If I use Fortran pointers as below, I get the "expected" output

MODULE foo
  USE iso_c_binding
  IMPLICIT NONE
  INTERFACE bar
    MODULE PROCEDURE bar_s
    MODULE PROCEDURE bar_a1d
  END INTERFACE bar
CONTAINS
  SUBROUTINE bar_s(a, b)
    real, pointer :: a, b
    WRITE (0, *) 'in bar_s'
  END SUBROUTINE bar_s

  SUBROUTINE bar_a1d(a, b)
    real, pointer :: a(:), b(:)
    WRITE (0, *) 'in bar_a1d'
  END SUBROUTINE bar_a1d
END MODULE foo

PROGRAM cptr_array_vs_scalar_arg
  USE foo
  USE iso_c_binding
  IMPLICIT NONE
  INTEGER, TARGET :: i
  real, pointer :: a, b
  real, pointer :: c(:), d(:)
  CALL bar(a, b)
  CALL bar(c, d)
END PROGRAM cptr_array_vs_scalar_arg

I don't understand how the code in comment 0 can distinguish bar_s from bar_a1d
based on the variable locations in memory, nor why it chooses bar_a1d.


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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
  2014-06-27 14:47 ` [Bug fortran/61615] " thatcadguy at gmail dot com
  2014-07-12 22:19 ` dominiq at lps dot ens.fr
@ 2014-07-13 15:09 ` dominiq at lps dot ens.fr
  2014-07-13 15:39 ` anlauf at gmx dot de
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-13 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> TKR, i.e. rank in the present case?

Doesn't it assume that TKR is available trough C_LOC(i)?


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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
                   ` (2 preceding siblings ...)
  2014-07-13 15:09 ` dominiq at lps dot ens.fr
@ 2014-07-13 15:39 ` anlauf at gmx dot de
  2014-07-13 16:08 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gmx dot de @ 2014-07-13 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Dominique d'Humieres from comment #4)
> > TKR, i.e. rank in the present case?
> 
> Doesn't it assume that TKR is available trough C_LOC(i)?

Well, my understanding is that

    TYPE(c_ptr) :: a, b

are pointers (void*) and

    TYPE(c_ptr) :: a(:), b(:)

are arrays of pointers (void**).

But I am not the author of the original code. ;-)


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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
                   ` (3 preceding siblings ...)
  2014-07-13 15:39 ` anlauf at gmx dot de
@ 2014-07-13 16:08 ` dominiq at lps dot ens.fr
  2015-10-09  8:58 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-13 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Well, my understanding is that
>
>     TYPE(c_ptr) :: a, b
>
> are pointers (void*) and
>
>     TYPE(c_ptr) :: a(:), b(:)
>
> are arrays of pointers (void**).

The result of -fdump-tree-original of

PROGRAM cptr_array_vs_scalar_arg
  USE iso_c_binding
  IMPLICIT NONE
  INTEGER, TARGET :: i, j(5)
  TYPE(c_ptr) :: a, b
  a = C_LOC(i)
  b = C_LOC(j)
END PROGRAM cptr_array_vs_scalar_arg

is

cptr_array_vs_scalar_arg ()
{
  void * a;
  void * b;
  integer(kind=4) i;
  integer(kind=4) j[5];

  {
    void * D.2336;

    D.2336 = (void *) &i;
    a = D.2336;
  }
  {
    void * D.2337;

    D.2337 = (void *) &j;
    b = D.2337;
  }
}


main (integer(kind=4) argc, character(kind=1) * * argv)
{
  static integer(kind=4) options.0[9] = {68, 1023, 0, 0, 1, 1, 0, 0, 31};

  _gfortran_set_args (argc, argv);
  _gfortran_set_options (9, &options.0[0]);
  cptr_array_vs_scalar_arg ();
  return 0;
}


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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
                   ` (4 preceding siblings ...)
  2014-07-13 16:08 ` dominiq at lps dot ens.fr
@ 2015-10-09  8:58 ` dominiq at lps dot ens.fr
  2023-04-11 14:56 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-09  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> IMO a bug in gfortran.

So moved to NEW.


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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
                   ` (5 preceding siblings ...)
  2015-10-09  8:58 ` dominiq at lps dot ens.fr
@ 2023-04-11 14:56 ` anlauf at gcc dot gnu.org
  2023-04-12  9:14 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-11 14:56 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org

--- Comment #9 from anlauf at gcc dot gnu.org ---
Patch: https://gcc.gnu.org/pipermail/fortran/2023-April/059166.html

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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
                   ` (6 preceding siblings ...)
  2023-04-11 14:56 ` anlauf at gcc dot gnu.org
@ 2023-04-12  9:14 ` cvs-commit at gcc dot gnu.org
  2023-04-12  9:21 ` anlauf at gcc dot gnu.org
  2023-04-23 18:53 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-12  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:c482995cc5bac4a2168ea0049041e712544e474b

commit r13-7145-gc482995cc5bac4a2168ea0049041e712544e474b
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Apr 11 16:44:32 2023 +0200

    Fortran: resolve correct generic with TYPE(C_PTR) arguments
[PR61615,PR99982]

    gcc/fortran/ChangeLog:

            PR fortran/61615
            PR fortran/99982
            * interface.cc (compare_parameter): Enable type and rank checks for
            arguments of derived type from the intrinsic module ISO_C_BINDING.

    gcc/testsuite/ChangeLog:

            PR fortran/61615
            PR fortran/99982
            * gfortran.dg/interface_49.f90: New test.

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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
                   ` (7 preceding siblings ...)
  2023-04-12  9:14 ` cvs-commit at gcc dot gnu.org
@ 2023-04-12  9:21 ` anlauf at gcc dot gnu.org
  2023-04-23 18:53 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-12  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #11 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-13.

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

* [Bug fortran/61615] Failure to resolve correct generic with TYPE(C_PTR) arguments
  2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
                   ` (8 preceding siblings ...)
  2023-04-12  9:21 ` anlauf at gcc dot gnu.org
@ 2023-04-23 18:53 ` cvs-commit at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-23 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:62a4f2fb356cab8cfebfeeac2895b657c32b8dd4

commit r12-9467-g62a4f2fb356cab8cfebfeeac2895b657c32b8dd4
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Apr 11 16:44:32 2023 +0200

    Fortran: resolve correct generic with TYPE(C_PTR) arguments
[PR61615,PR99982]

    gcc/fortran/ChangeLog:

            PR fortran/61615
            PR fortran/99982
            * interface.cc (compare_parameter): Enable type and rank checks for
            arguments of derived type from the intrinsic module ISO_C_BINDING.

    gcc/testsuite/ChangeLog:

            PR fortran/61615
            PR fortran/99982
            * gfortran.dg/interface_49.f90: New test.

    (cherry picked from commit c482995cc5bac4a2168ea0049041e712544e474b)

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

end of thread, other threads:[~2023-04-23 18:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-25 22:48 [Bug fortran/61615] New: Failure to resolve correct generic with TYPE(C_PTR) arguments thatcadguy at gmail dot com
2014-06-27 14:47 ` [Bug fortran/61615] " thatcadguy at gmail dot com
2014-07-12 22:19 ` dominiq at lps dot ens.fr
2014-07-13 15:09 ` dominiq at lps dot ens.fr
2014-07-13 15:39 ` anlauf at gmx dot de
2014-07-13 16:08 ` dominiq at lps dot ens.fr
2015-10-09  8:58 ` dominiq at lps dot ens.fr
2023-04-11 14:56 ` anlauf at gcc dot gnu.org
2023-04-12  9:14 ` cvs-commit at gcc dot gnu.org
2023-04-12  9:21 ` anlauf at gcc dot gnu.org
2023-04-23 18:53 ` cvs-commit 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).