From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32640 invoked by alias); 25 Jan 2012 13:30:14 -0000 Received: (qmail 32629 invoked by uid 22791); 25 Jan 2012 13:30:12 -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; Wed, 25 Jan 2012 13:29:59 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/51995] [OOP] Polymorphic class fails at runtime Date: Wed, 25 Jan 2012 13:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: burnus at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status AssignedTo Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2012-01/txt/msg02923.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51995 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |burnus at gcc dot gnu.org |gnu.org | --- Comment #8 from Tobias Burnus 2012-01-25 13:29:48 UTC --- (In reply to comment #4) > I tested the program on i686 GNU/Linux running on Ubuntu-Maverick using gcc > version 4.7.0 20120118 (experimental) (GCC). > > So it is definitely a bug in gfortran. Do you have any work-around? Unfortunately, I am not aware of a workaround. I have to admit that I have not fully understood why fclass->f2k_derived gets often but not always set. However, the following patch works. Thus, you could either apply it and build your own GCC, or you wait a day after the committal and get a nightly build at http://gcc.gnu.org/wiki/GFortranBinaries - or you convince Matthias to do a new Ubuntu build. (In reply to comment #7) > There, the problem is that one has: > sym = sym->ts.u.derived; > if (sym->f2k_derived) Actually, f2k_derived should also get set for the class container. Better patch (read: actually working) patch: --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -421,6 +421,8 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr, c->attr.access = ACCESS_PRIVATE; c->attr.pointer = 1; } + else if (!fclass->f2k_derived) + fclass->f2k_derived = fclass->components->ts.u.derived->f2k_derived; /* Since the extension field is 8 bit wide, we can only have up to 255 extension levels. */