public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49112] New: Missing type-bound procedure, "duplicate save" warnings and internal compiler error
@ 2011-05-22 16:28 jwmwalrus at gmail dot com
  2011-05-22 16:31 ` [Bug fortran/49112] " jwmwalrus at gmail dot com
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: jwmwalrus at gmail dot com @ 2011-05-22 16:28 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Missing type-bound procedure, "duplicate save"
                    warnings and internal compiler error
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jwmwalrus@gmail.com


When I compile the following module:

module datetime_mod
    implicit none
    private
    save

    type, public :: DateTime
        integer :: year = 0, month = 0, day = 0, hh = 0, mm = 0, ss = 0, &
                   sss = 0
    contains
        procedure :: getString
        procedure :: getDateString
        procedure :: getTimeString
        procedure, private :: getFormattedString
    end type

    type(DateTime), parameter :: &                                      !***
        ISO_REFERENCE_DATE = DateTime(1875, 5, 20, 0, 0, 0, 0), &       !***
        GREGORIAN_REFERENCE_DATE = DateTime(1582, 10, 15, 0, 0, 0, 0)   !***

contains
    function getString(dt, FMT) result(string)
        character(:), allocatable :: string
        class(DateTime), intent(IN) :: dt
        integer, optional, intent(IN) :: FMT
    continue
        string = dt%getFormattedString(0, FMT)
    end function 

    function getDateString(dt, FMT) result(string)
        character(:), allocatable :: string
        class(DateTime), intent(IN) :: dt
        integer, optional, intent(IN) :: FMT
    continue
        string = dt%getFormattedString(1, FMT)
    end function 

    function getTimeString(dt, FMT) result(string)
        character(:), allocatable :: string
        class(DateTime), intent(IN) :: dt
        integer, optional, intent(IN) :: FMT
    continue
        string = dt%getFormattedString(2, FMT)
    end function 

    elemental function getFormattedString(this, FILTER, FMT) &
        result(string)
        character(:), allocatable :: string
        class(DateTime), intent(IN) :: this
        integer, optional, intent(IN) :: FILTER, FMT
    continue
        string = ''
    end function
end module datetime_mod



gfortran does not recognize getFormattedString as a type-bound procedure. 
There are also errors related to the use of a deferred-length character as a
function result (reported as Bug 49110), and an unnecessary warning about the
duplicate save attribute.  The exact output is:

...:~$ gfortran -c  test_gfortran_missing_tbp.f90 
test_gfortran_missing_tbp.f90:27.38:

        string = dt%getFormattedString(0, FMT)
                                      1
Error: 'getformattedstring' at (1) is not a member of the 'datetime' structure
test_gfortran_missing_tbp.f90:35.38:

        string = dt%getFormattedString(1, FMT)
                                      1
Error: 'getformattedstring' at (1) is not a member of the 'datetime' structure
test_gfortran_missing_tbp.f90:43.38:

        string = dt%getFormattedString(2, FMT)
                                      1
Error: 'getformattedstring' at (1) is not a member of the 'datetime' structure
test_gfortran_missing_tbp.f90:46.4:

    elemental function getFormattedString(dt, FILTER, FMT) &
    1
Error: CHARACTER(*) function 'getformattedstring' at (1) cannot be pure
test_gfortran_missing_tbp.f90:46.4:

    elemental function getFormattedString(dt, FILTER, FMT) &
    1
Error: CHARACTER(*) function 'getformattedstring' at (1) cannot be pure
test_gfortran_missing_tbp.f90:46.4:

    elemental function getFormattedString(dt, FILTER, FMT) &
    1
Error: CHARACTER(*) function 'getformattedstring' at (1) cannot be pure
test_gfortran_missing_tbp.f90:18.62:

        ISO_REFERENCE_DATE = DateTime(1875, 5, 20, 0, 0, 0, 0), &       !***
                                                              1
Warning: Duplicate SAVE attribute specified at (1)
test_gfortran_missing_tbp.f90:18.62:

        ISO_REFERENCE_DATE = DateTime(1875, 5, 20, 0, 0, 0, 0), &       !***
                                                              1
Warning: Duplicate SAVE attribute specified at (1)



If I remove the three lines marked with "!***" and also remove the ELEMENTAL
attribute from the getFormattedString function, and compile again, then I get
an internal compiler error:

...:~$ gfortran -c  test_gfortran_ice.f90 
test_gfortran_ice.f90:20.41:

        class(DateTime), intent(IN) :: dt
                                         1
Warning: Duplicate SAVE attribute specified at (1)
test_gfortran_ice.f90:20.41:

        class(DateTime), intent(IN) :: dt
                                         1
Warning: Duplicate SAVE attribute specified at (1)
test_gfortran_ice.f90: In function ‘gettimestring’:
test_gfortran_ice.f90:41:0: internal compiler error: in fold_convert_loc, at
fold-const.c:1906
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions




The version information is:

...:~$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.6.0-3~ppa1'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-multiarch
--with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib/x86_64-linux-gnu
--enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror
--with-arch-32=i686 --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 4.6.1 20110409 (prerelease) (Ubuntu 4.6.0-3~ppa1) 


The system information (for Ubuntu 11.04) is:

...:~$ uname -srvmpio
Linux 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 x86_64
x86_64 x86_64 GNU/Linux


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

end of thread, other threads:[~2011-08-05 17:07 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-22 16:28 [Bug fortran/49112] New: Missing type-bound procedure, "duplicate save" warnings and internal compiler error jwmwalrus at gmail dot com
2011-05-22 16:31 ` [Bug fortran/49112] " jwmwalrus at gmail dot com
2011-05-22 16:35 ` jwmwalrus at gmail dot com
2011-05-22 17:41 ` janus at gcc dot gnu.org
2011-05-22 18:19 ` jwmwalrus at gmail dot com
2011-05-28 10:31 ` [Bug fortran/49112] [4.6/4.7 Regression] [OOP] " janus at gcc dot gnu.org
2011-05-28 10:52 ` janus at gcc dot gnu.org
2011-05-28 11:09 ` janus at gcc dot gnu.org
2011-05-28 16:31 ` jwmwalrus at gmail dot com
2011-05-30 20:01 ` janus at gcc dot gnu.org
2011-05-30 20:11 ` janus at gcc dot gnu.org
2011-06-12 12:40 ` rguenth at gcc dot gnu.org
2011-06-20 19:56 ` janus at gcc dot gnu.org
2011-06-21 12:13 ` janus at gcc dot gnu.org
2011-06-21 12:21 ` janus at gcc dot gnu.org
2011-06-21 12:27 ` janus at gcc dot gnu.org
2011-06-27 16:30 ` jakub at gcc dot gnu.org
2011-06-27 17:46 ` janus at gcc dot gnu.org
2011-07-27 19:52 ` burnus at gcc dot gnu.org
2011-07-27 21:57 ` janus at gcc dot gnu.org
2011-07-31 10:25 ` janus at gcc dot gnu.org
2011-08-05 17:04 ` janus at gcc dot gnu.org
2011-08-05 17:07 ` janus 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).