public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43169]  New: gfortran rejects pure procedure with select type construct
@ 2010-02-24 20:14 haymaker at mail dot utexas dot edu
  2010-02-25  8:38 ` [Bug fortran/43169] [OOP] " janus at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: haymaker at mail dot utexas dot edu @ 2010-02-24 20:14 UTC (permalink / raw)
  To: gcc-bugs

The following code fails to compile with gcc version 4.5.0-pre9999 20100224
(experimental) rev. 157053. However, if lines 22, 23 and 27 (i.e. 'select
type(x)', 'class is (myType)', and 'end select') are removed it compiles fine
and the executable gives the expected output '2.0000 1.0000'.

Source compiled with ifort v. 11.1 behaves as expected with 'select type'
construct included. 

$ cat test.f90 && gfortran test.f90                             
program testPure
implicit none
type :: myType
    real :: a,b
end type myType
type(myType),target :: y
class(myType),pointer :: x

x=>y
x%a=1.
x%b=2.
call swap(x)
print *, x%a,x%b

contains

pure subroutine swap(x)
implicit none
class(myType), intent(inout) :: x
real :: work

select type(x)
class is (myType)
    work=x%a
    x%a=x%b
    x%b=work
end select
end subroutine swap
end program testPure
test.f90:25.4:

    x%a=x%b
    1
Error: Cannot assign to variable 'tmp$class$mytype' in PURE procedure at (1)
test.f90:26.4:

    x%b=work
    1
Error: Cannot assign to variable 'tmp$class$mytype' in PURE procedure at (1)

********************
Now with 'select type' construct removed


$ cat test.f90 && gfortran test.f90 && ./a.out                   
--(Wed,Feb24)--
program testPure
implicit none
type :: myType
    real :: a,b
end type myType
type(myType),target :: y
class(myType),pointer :: x

x=>y
x%a=1.
x%b=2.
call swap(x)
print *, x%a,x%b

contains

pure subroutine swap(x)
implicit none
class(myType), intent(inout) :: x
real :: work

    work=x%a
    x%a=x%b
    x%b=work
end subroutine swap
end program testPure

   2.0000000       1.0000000


-------------------------------------
gcc configure options:
$ gcc -v
gcc -v                                                          
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0-pre9999/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0-pre9999/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.5.0_pre9999/work/gcc-4.5.0-9999/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0-pre9999
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0-pre9999/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0-pre9999
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0-pre9999/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0-pre9999/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0-pre9999/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --enable-nls
--without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --enable-multilib --enable-libmudflap
--disable-libssp --enable-libgomp --enable-cld
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.0-pre9999/python
--disable-libgcj --enable-languages=c,c++,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo SVN'
--enable-lto --disable-checking
Thread model: posix
gcc version 4.5.0-pre9999 20100224 (experimental) rev. 157053 (Gentoo SVN)


-- 
           Summary: gfortran rejects pure procedure with select type
                    construct
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: haymaker at mail dot utexas dot edu
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


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


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

end of thread, other threads:[~2010-03-03 15:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-24 20:14 [Bug fortran/43169] New: gfortran rejects pure procedure with select type construct haymaker at mail dot utexas dot edu
2010-02-25  8:38 ` [Bug fortran/43169] [OOP] " janus at gcc dot gnu dot org
2010-02-25  9:09 ` janus at gcc dot gnu dot org
2010-02-25  9:14 ` janus at gcc dot gnu dot org
2010-02-25  9:19 ` janus at gcc dot gnu dot org
2010-02-25 12:17 ` janus at gcc dot gnu dot org
2010-02-25 12:55 ` janus at gcc dot gnu dot org
2010-02-25 13:40 ` janus at gcc dot gnu dot org
2010-02-28 15:08 ` domob at gcc dot gnu dot org
2010-03-01 12:47 ` janus at gcc dot gnu dot org
2010-03-03 15:13 ` janus at gcc dot gnu dot org
2010-03-03 15:17 ` janus at gcc dot gnu dot 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).