[Bug fortran/78395] [OOP] ICE for operations with polymorphic variables

2016-11-17 Thread cmacmackin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78395

--- Comment #6 from Chris  ---
> Which one do you mean exactly? Shouldn't they all use the user-defined 
> assignment function?

Yes, that's right--they all should. Sorry, I didn't have the code up in front
of me when I wrote that so I was a bit imprecise in what I was saying.

[Bug fortran/78395] [OOP] ICE for operations with polymorphic variables

2016-11-17 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78395

--- Comment #5 from janus at gcc dot gnu.org ---
(In reply to Chris from comment #4)
> I tried compiling (my original example) on a different box, this one with
> gfortran 6.2.0 obtained from the ubuntu-toolchain-r/test PPA. I got
> 
> [..]
> gcc version 6.2.0 20160901 (Ubuntu 6.2.0-3ubuntu11~16.04) 

My gfortran-6 version is what currently is in Ubuntu 16.10:

gcc version 6.2.0 20161005 (Ubuntu 6.2.0-5ubuntu12)

and that does not give an ICE, but the error shown above.


> Would there be some issue with the build which is causing the ICE for me?

Not sure. Since our versions differ a bit, the most probable scenario is that
the different behavior was caused by some recent backport (unfortunately Ubuntu
does not give exact revision numbers). One should check the logfile:

https://gcc.gnu.org/viewcvs/gcc/branches/gcc-6-branch/gcc/fortran/ChangeLog?view=markup


> The error message which you reported for gfortran 6.2.0 also doesn't make
> sense to me, as I use defined-assignment to allocatable variables frequently
> in my code without problem.

True. Didn't notice that. I guess the error should only apply to intrinsic
assignment, not user-defined. So maybe that's a bug after all.


> Indeed, it is used a line or two earlier in the
> example I provided.

Which one do you mean exactly? Shouldn't they all use the user-defined
assignment function?

In any case the error is thrown on the last line, and I also get it on the
reduced example in comment 3:


$ gfortran-6 c3.f90 
c3.f90:62:2:

   v6 = 3 * v4%get_t2() ! This line is the one which causes ICE
  1
Error: Assignment to an allocatable polymorphic variable at (1) is not yet
supported

[Bug fortran/78395] [OOP] ICE for operations with polymorphic variables

2016-11-17 Thread cmacmackin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78395

--- Comment #4 from Chris  ---
I tried compiling (my original example) on a different box, this one with
gfortran 6.2.0 obtained from the ubuntu-toolchain-r/test PPA. I got

Driving: gfortran-6 -v minimal.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran-6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
6.2.0-3ubuntu11~16.04' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-6 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.2.0 20160901 (Ubuntu 6.2.0-3ubuntu11~16.04) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/6/f951 minimal.f90 -quiet -dumpbase minimal.f90
-mtune=generic -march=x86-64 -auxbase minimal -version -fintrinsic-modules-path
/usr/lib/gcc/x86_64-linux-gnu/6/finclude -o /tmp/chris/ccDLOYCy.s
GNU Fortran (Ubuntu 6.2.0-3ubuntu11~16.04) version 6.2.0 20160901
(x86_64-linux-gnu)
compiled by GNU C version 6.2.0 20160901, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (Ubuntu 6.2.0-3ubuntu11~16.04) version 6.2.0 20160901
(x86_64-linux-gnu)
compiled by GNU C version 6.2.0 20160901, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
f951: internal compiler error: in gfc_add_component_ref, at fortran/class.c:241
0x5dede4 gfc_add_component_ref(gfc_expr*, char const*)
../../src/gcc/fortran/class.c:241
0x6564f1 resolve_typebound_function
../../src/gcc/fortran/resolve.c:6014
0x6564f1 gfc_resolve_expr(gfc_expr*)
../../src/gcc/fortran/resolve.c:6357
0x60730a gfc_extend_expr(gfc_expr*)
../../src/gcc/fortran/interface.c:3943
0x656064 resolve_operator
../../src/gcc/fortran/resolve.c:3850
0x656064 gfc_resolve_expr(gfc_expr*)
../../src/gcc/fortran/resolve.c:6339
0x65cab3 gfc_resolve_code(gfc_code*, gfc_namespace*)
../../src/gcc/fortran/resolve.c:10459
0x65f282 resolve_codes
../../src/gcc/fortran/resolve.c:15656
0x65f37e gfc_resolve(gfc_namespace*)
../../src/gcc/fortran/resolve.c:15691
0x64a62a resolve_all_program_units
../../src/gcc/fortran/parse.c:5854
0x64a62a gfc_parse_file()
../../src/gcc/fortran/parse.c:6106
0x68c1c2 gfc_be_parse_file
../../src/gcc/fortran/f95-lang.c:201
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

Would there be some issue with the build which is causing the ICE for me? The
error message which you reported for gfortran 6.2.0 also doesn't make sense to
me, as I use defined-assignment to allocatable variables frequently in my code
without problem. Indeed, it is used a line or two earlier in the example I
provided.

[Bug fortran/78395] [OOP] ICE for operations with polymorphic variables

2016-11-17 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78395

--- Comment #3 from janus at gcc dot gnu.org ---
Somewhat reduced test case (without all the abstract stuff):


module types_mod
  implicit none

  type, public :: t1
integer :: a
  contains
procedure :: get_t2
  end type

  type, public :: t2
integer :: b
  contains
procedure, pass(rhs) :: mul2
procedure :: assign
generic :: operator(*) => mul2
generic :: assignment(=) => assign
  end type

contains

  function get_t2(this)
class(t1), intent(in) :: this
class(t2), allocatable :: get_t2
type(t2), allocatable :: local
allocate(local)
local%b = this%a
call move_alloc(local, get_t2)
  end function

  function mul2(lhs, rhs)
class(t2), intent(in) :: rhs
integer, intent(in) :: lhs
class(t2), allocatable :: mul2
type(t2), allocatable :: local
allocate(local)
local%b = rhs%b*lhs
call move_alloc(local, mul2)
  end function

  subroutine assign(this, rhs)
class(t2), intent(out) :: this
class(t2), intent(in)  :: rhs
select type(rhs)
type is(t2)
  this%b = rhs%b
class default
  error stop
end select
  end subroutine

end module


program minimal
  use types_mod
  implicit none

  class(t1), allocatable :: v4
  class(t2), allocatable :: v6

  allocate(v4, source=t1(4)) ! Also fails if I use `allocate(t1 :: v4)`
  v6 = 3 * v4%get_t2() ! This line is the one which causes ICE

end

[Bug fortran/78395] [OOP] ICE for operations with polymorphic variables

2016-11-17 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78395

janus at gcc dot gnu.org changed:

   What|Removed |Added

 CC||vehre at gcc dot gnu.org

--- Comment #2 from janus at gcc dot gnu.org ---
(In reply to janus from comment #1)
> gfortran 6.2.0 says:
> 
>v6 = 3 * v4%get_t2() ! This line is the one which causes ICE
>   1
> Error: Assignment to an allocatable polymorphic variable at (1) is not yet
> supported

It seems this error message was removed on trunk by Andre's r241439.

[Bug fortran/78395] [OOP] ICE for operations with polymorphic variables

2016-11-17 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78395

janus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-11-17
 CC||janus at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from janus at gcc dot gnu.org ---
I can confirm the ICE in gfc_add_component_ref only with gfortran 5.4.1 and
earlier.


gfortran 6.2.0 says:

   v6 = 3 * v4%get_t2() ! This line is the one which causes ICE
  1
Error: Assignment to an allocatable polymorphic variable at (1) is not yet
supported


And a current trunk build:


   v6 = 3 * v4%get_t2() ! This line is the one which causes ICE
   1
Error: Can't convert TYPE(__vtype_types_mod_A1) to CLASS(a2) at (1)


The error with 6.2 is acceptable, I guess, but the one with trunk is not so
nice.