From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1596 invoked by alias); 30 Aug 2015 15:39:03 -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 Received: (qmail 1557 invoked by uid 48); 30 Aug 2015 15:38:59 -0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/59398] Wrong bounds for allocatable result and for Date: Sun, 30 Aug 2015 15:39: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-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg02060.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59398 Dominique d'Humieres changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #10 from Dominique d'Humieres --- > That seems to be the case. For the moment, the lesson I learnt is never > to return arrays with a lower bound different from 1. The following variant program return_allocatable implicit none real, allocatable :: a(:) real, parameter :: b(-2:4)=[1,2,3,4,5,6,7] a=b print*,lbound(a),':',ubound(a) deallocate(a) a=foo(3) print*,lbound(a),':',ubound(a) contains function foo(n) result(res) integer :: n real, allocatable :: res(:) allocate(res(-3:n)) res=n print *, lbound(res), ubound(res) end function end program gives (with the default -frealloc-lhs) -2 : 4 -3 3 1 : 7 Is this correct? > This kind of sucks. Why having lower bounds different than 0 sometimes only? > Either have them, or don't! In Fortran the default lower bounds are always 1 and never 0.