public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
@ 2021-01-06 14:57 yves.secretan at ete dot inrs.ca
  2021-01-20 14:20 ` [Bug fortran/98565] " dominiq at lps dot ens.fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: yves.secretan at ete dot inrs.ca @ 2021-01-06 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98565
           Summary: internal compiler error: in conv_function_val, at
                    fortran/trans-expr.c:3950
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yves.secretan at ete dot inrs.ca
  Target Milestone: ---

Created attachment 49900
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49900&action=edit
Toy reproducer

Hello,

Attempting to use directly a returned pointer in an associated statement
triggers an ICE. A bypass is to use an intermediate variable. Attached is a toy
reproducer.

h2d2@ubuntu:~/inrs-dev/H2D2$ gfortran -v bug_gfortran_ice.f90 
Driving: gfortran -v bug_gfortran_ice.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/debian/tmp-nvptx/usr,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/f951 bug_gfortran_ice.f90 -quiet -dumpbase
bug_gfortran_ice.f90 -mtune=generic -march=x86-64 -auxbase bug_gfortran_ice
-version -fintrinsic-modules-path /usr/lib/gcc/x86_64-linux-gnu/9/finclude
-fpre-include=/usr/include/finclude/math-vector-fortran.h -o /tmp/ccE8ZwpJ.s
GNU Fortran (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2,
MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (Ubuntu 9.3.0-17ubuntu1~20.04) version 9.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 9.3.0, GMP version 6.2.0, MPFR version 4.0.2,
MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
bug_gfortran_ice.f90:54:0:

   54 |    ISOK = ASSOCIATED(SELF%PGRID, OELE%REQPGRID())
      | 
internal compiler error: in conv_function_val, at fortran/trans-expr.c:3926
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-9/README.Bugs> for instructions.

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

* [Bug fortran/98565] internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
  2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
@ 2021-01-20 14:20 ` dominiq at lps dot ens.fr
  2021-01-22 15:59 ` pault at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-01-20 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-01-20
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from GCC7 up to GCC11, no option needed. This correspond to

      gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == POINTER_TYPE
              && TREE_CODE (TREE_TYPE (TREE_TYPE (tmp))) == FUNCTION_TYPE);

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

* [Bug fortran/98565] internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
  2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
  2021-01-20 14:20 ` [Bug fortran/98565] " dominiq at lps dot ens.fr
@ 2021-01-22 15:59 ` pault at gcc dot gnu.org
  2021-01-22 17:11 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2021-01-22 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 50036
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50036&action=edit
Fix for the PR

Dear Yves,

I will be committing this patch to master this evening, after it has completed
regression testing, together with the testcase below. I will apply to 9- and
10-branches in a few weeks time.

You will note that I have made the components public so that I do not need to
write constructors.

Many thanks for the report. I hope that the fix will help your work in support
of sustainable development in Amazonia, even if in an insignificant way.

Regards

Paul

! { dg-do run }
!
! associated_target_7.f90: Test the fix for PR98565.
!
! Contributed by Yves Secretan  <yves.secretan@ete.inrs.ca>
!
MODULE PS_SN0N_M

   IMPLICIT NONE
   PRIVATE

   TYPE, PUBLIC :: DT_GRID_T
       INTEGER :: NNT
   CONTAINS
       ! PASS
   END TYPE DT_GRID_T

   TYPE, PUBLIC :: LM_ELEM_T
       CLASS(DT_GRID_T), POINTER :: PGRID
   CONTAINS
       PROCEDURE, PUBLIC :: REQPGRID => LM_ELEM_REGPGRID
   END TYPE LM_ELEM_T

   TYPE, PUBLIC :: PS_SN0N_T
      CLASS(DT_GRID_T), POINTER :: PGRID

   CONTAINS
      PROCEDURE, PUBLIC :: ASGOELE  => PS_SN0N_ASGOELE
   END TYPE PS_SN0N_T


CONTAINS
   !------------------------------------------------------------------------
   !------------------------------------------------------------------------
   FUNCTION LM_ELEM_REGPGRID(SELF) RESULT(PGRID)
   CLASS(DT_GRID_T), POINTER :: PGRID
   CLASS(LM_ELEM_T), INTENT(IN) :: SELF
   PGRID => SELF%PGRID
   RETURN
   END FUNCTION LM_ELEM_REGPGRID

   !------------------------------------------------------------------------
   !------------------------------------------------------------------------
   FUNCTION PS_SN0N_ASGOELE(SELF, OELE) RESULT(ERMSG)

   INTEGER :: ERMSG
   CLASS(PS_SN0N_T), INTENT(IN) :: SELF
   CLASS(LM_ELEM_T), INTENT(IN) :: OELE

   !CLASS(DT_GRID_T), POINTER :: PGRID
   LOGICAL :: ISOK
   !------------------------------------------------------------------------

   ! ASSOCIATED with temp variable compiles
   !PGRID => OELE%REQPGRID()
   !ISOK = ASSOCIATED(SELF%PGRID, PGRID)

   ! ASSOCIATE without temp variable crashes with ICE
   ISOK = ASSOCIATED(SELF%PGRID, OELE%REQPGRID())
   ERMSG = 0
   IF (ISOK) ERMSG = 1

   RETURN
   END FUNCTION PS_SN0N_ASGOELE

END MODULE PS_SN0N_M


   USE PS_SN0N_M
   CLASS(PS_SN0N_T), ALLOCATABLE :: SELF
   CLASS(LM_ELEM_T), ALLOCATABLE :: OELE
   TYPE (DT_GRID_T), TARGET :: GRID1 = DT_GRID_T (42)
   TYPE (DT_GRID_T), TARGET :: GRID2 = DT_GRID_T (84)

   ALLOCATE (PS_SN0N_T :: SELF)
   ALLOCATE (LM_ELEM_T :: OELE)
   SELF%PGRID => GRID1

   OELE%PGRID => NULL ()
   IF (SELF%ASGOELE (OELE) .NE. 0) STOP 1

   OELE%PGRID => GRID2
   IF (SELF%ASGOELE (OELE) .NE. 0) STOP 2

   OELE%PGRID => GRID1
   IF (SELF%ASGOELE (OELE) .NE. 1) STOP 3
END

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

* [Bug fortran/98565] internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
  2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
  2021-01-20 14:20 ` [Bug fortran/98565] " dominiq at lps dot ens.fr
  2021-01-22 15:59 ` pault at gcc dot gnu.org
@ 2021-01-22 17:11 ` cvs-commit at gcc dot gnu.org
  2021-05-04 12:31 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-22 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r11-6863-gbf8ee9e4eed6ba1a6d77b4cf168df480e1f954da
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Jan 22 17:11:06 2021 +0000

    Fortran: Fix for class functions as associated target [PR98565].

    2021-01-22  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/98565
            * trans-intrinsic.c (gfc_conv_associated): Do not add a _data
            component for scalar class function targets. Instead, fix the
            function result and access the _data from that.

    gcc/testsuite/
            PR fortran/98565
            * gfortran.dg/associated_target_7.f90 : New test.

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

* [Bug fortran/98565] internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
  2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
                   ` (2 preceding siblings ...)
  2021-01-22 17:11 ` cvs-commit at gcc dot gnu.org
@ 2021-05-04 12:31 ` rguenth at gcc dot gnu.org
  2021-09-10 20:35 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-04 12:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

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

* [Bug fortran/98565] internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
  2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
                   ` (3 preceding siblings ...)
  2021-05-04 12:31 ` rguenth at gcc dot gnu.org
@ 2021-09-10 20:35 ` cvs-commit at gcc dot gnu.org
  2021-09-10 20:36 ` anlauf at gcc dot gnu.org
  2021-09-10 20:49 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-10 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:5bb6119070a7aab95dad3bcf3cdf8ac2bc818488

commit r9-9721-g5bb6119070a7aab95dad3bcf3cdf8ac2bc818488
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Jan 22 17:11:06 2021 +0000

    Fortran: Fix for class functions as associated target [PR98565].

    2021-01-22  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/98565
            * trans-intrinsic.c (gfc_conv_associated): Do not add a _data
            component for scalar class function targets. Instead, fix the
            function result and access the _data from that.

    gcc/testsuite/
            PR fortran/98565
            * gfortran.dg/associated_target_7.f90 : New test.

    (cherry picked from commit bf8ee9e4eed6ba1a6d77b4cf168df480e1f954da)

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

* [Bug fortran/98565] internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
  2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
                   ` (4 preceding siblings ...)
  2021-09-10 20:35 ` cvs-commit at gcc dot gnu.org
@ 2021-09-10 20:36 ` anlauf at gcc dot gnu.org
  2021-09-10 20:49 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-10 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #5 from anlauf at gcc dot gnu.org ---
Backported Paul's fix to remaining open branches after verifying that it does
the job.  Closing.

Thanks to all!

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

* [Bug fortran/98565] internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950
  2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
                   ` (5 preceding siblings ...)
  2021-09-10 20:36 ` anlauf at gcc dot gnu.org
@ 2021-09-10 20:49 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-10 20:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:755299ea93dd064ab5ec1027a34f30ca2d908f4c

commit r10-10110-g755299ea93dd064ab5ec1027a34f30ca2d908f4c
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Jan 22 17:11:06 2021 +0000

    Fortran: Fix for class functions as associated target [PR98565].

    2021-01-22  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/98565
            * trans-intrinsic.c (gfc_conv_associated): Do not add a _data
            component for scalar class function targets. Instead, fix the
            function result and access the _data from that.

    gcc/testsuite/
            PR fortran/98565
            * gfortran.dg/associated_target_7.f90 : New test.

    (cherry picked from commit bf8ee9e4eed6ba1a6d77b4cf168df480e1f954da)

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

end of thread, other threads:[~2021-09-10 20:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06 14:57 [Bug fortran/98565] New: internal compiler error: in conv_function_val, at fortran/trans-expr.c:3950 yves.secretan at ete dot inrs.ca
2021-01-20 14:20 ` [Bug fortran/98565] " dominiq at lps dot ens.fr
2021-01-22 15:59 ` pault at gcc dot gnu.org
2021-01-22 17:11 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2021-09-10 20:35 ` cvs-commit at gcc dot gnu.org
2021-09-10 20:36 ` anlauf at gcc dot gnu.org
2021-09-10 20:49 ` 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).