From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27624 invoked by alias); 20 Dec 2010 09:35:34 -0000 Received: (qmail 27464 invoked by uid 22791); 20 Dec 2010 09:35:34 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Dec 2010 09:35:29 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/47024] New: [OOP] STORAGE_SIZE (for polymorphic types): Segfault at run time X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 20 Dec 2010 09:35:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-12/txt/msg02343.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47024 Summary: [OOP] STORAGE_SIZE (for polymorphic types): Segfault at run time Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org CC: janus@gcc.gnu.org STORAGE_SIZE does not work for unallocated polymorphic types. However, the Fortran 2008 standard allows them: "A shall be a scalar or array of any type. If it is polymorphic it shall not be an undefined pointer. If it has any deferred type parameters it shall not be an unallocated allocatable variable or a disassociated or undefined pointer." (F2008, 13.7.160) Note: The standard allows an unallocated polymorphic variable - as long as the type does not have any deferred type parameter. Fortunately, CLASS(*) does not seem to be allowed as "CLASS(*)" has no type. Maybe one should cross check (e.g. at the J3 mailing list) to see whether the proper result is the declared type or something else. implicit none type t integer :: a end type t type, extends(t) :: t2 integer :: b end type t2 class(t), allocatable :: y print *, storage_size(y)/8 ! Expected: "4"; in reality: segfault end