From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18266 invoked by alias); 5 Jul 2012 16:33:02 -0000 Received: (qmail 18222 invoked by uid 22791); 5 Jul 2012 16:32:59 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED,TW_HN 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; Thu, 05 Jul 2012 16:32:46 +0000 From: "j.moyard at voila dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/53818] -finit-local-zero -fno-automatic: Function result cannot have initializer Date: Thu, 05 Jul 2012 16:33: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: j.moyard at voila dot fr X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: 2012-07/txt/msg00543.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53818 --- Comment #5 from johnjohn 2012-07-05 16:32:44 UTC --- (In reply to comment #3) > (In reply to comment #0) > > But when I integrate '-fno-automatic' option, I obtain this error message : > > function testing(date1, date2) result(test) > > 1 > > Error: Function result 'test' at (1) cannot have an initializer > > I helps if you tell up all options. The issue seemingly only occurs with > -fno-automatic *and* -finit-local-zero (or -finit-logical=true|false). > > > Two things surprise me: > > a) Why are there two initializer, when looking at the dump > (-fdump-tree-original). (Requires that one does not have -fno-automatic) - the > should be only one, shouldn't it? > > > b) Why does this only trigger with -fno-automatic? The code currently has the > following. At a glance, it should always trigger and the > apply_default_init_local should be after the checks (together with the > simplify): > > resolve_fl_variable (gfc_symbol *sym, int mp_flag) > ... > if (sym->value == NULL && sym->attr.referenced) > apply_default_init_local (sym); /* Try to apply a default initialization. > */ > ... > /* Reject illegal initializers. */ > if (!sym->mark && sym->value) > ... > else if (sym->attr.result) > gfc_error ("Function result '%s' at %L cannot have an initializer", > sym->name, &sym->declared_at); Yes in fact, I use finit-local with fno-automatic!