From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26312 invoked by alias); 15 Jan 2013 14:48:09 -0000 Received: (qmail 25207 invoked by uid 48); 15 Jan 2013 14:47:32 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55978] [4.8 Regression] class_optional_2.f90 -Os fails Date: Tue, 15 Jan 2013 14:48: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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 X-Bugzilla-Changed-Fields: 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: 2013-01/txt/msg01355.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55978 --- Comment #7 from Tobias Burnus 2013-01-15 14:47:31 UTC --- (In reply to comment #6) > Looks as if code of the form: > if (y.data) > D.1914 = _gfortran_internal_pack (&y); > else > D.1914 = NULL; > > is missing The bug is in trans-array.c's gfc_conv_array_parameter, which currently has: 7156 ptr = build_call_expr_loc (input_location, 7157 gfor_fndecl_in_pack, 1, desc); 7158 7159 if (fsym && fsym->attr.optional && sym && sym->attr.optional) 7160 { 7161 tmp = gfc_conv_expr_present (sym); If the actual argument has sym->attr.optional, the code should work. Looking at line 39 of class_optional_2.f90, there seems to be something not working, which might be a bug in gfc_conv_expr_present. If sym->attr.optional is not present, it is currently not handled by gfc_conv_expr_present (assert). Similarly, if the actual argument is an expression like "var%comp" - here, the ".data == NULL" check has to be done for "comp" and not for "var" alias "sym". Similarly for expressions instead of variables. (There are presumably more issues.)