From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5211 invoked by alias); 9 May 2012 15:37:03 -0000 Received: (qmail 5002 invoked by uid 22791); 9 May 2012 15:37:01 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED 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, 09 May 2012 15:36:48 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/45424] F2008: Add is_contiguous intrinsic Date: Wed, 09 May 2012 15:38: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: 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: 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-05/txt/msg01022.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45424 --- Comment #1 from Tobias Burnus 2012-05-09 15:36:40 UTC --- Created attachment 27359 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27359 Draft patch: is_contiguous.diff Attached is a mostly ready patch for IS_CONTIGUOUS. The main TODO is to understand when IS_CONTIGUOUS should print .TRUE. and when .FALSE. The standard is not very clear about it, cf. 5.3.7 of F2008. a) Array element with nonzero strides (which is still a single array element): "a(1:1:1)" vs. "a(1:1:5)". With the attached patch but also with ifort and crayftn, the result is .true. and .false. The attached patch only checks the "stride", ignoring the number of elements. b) The same - but instead of a single element, using zero-sized arrays: a(2:1:1) vs. a(2:1:2). c) The following example is mishandled as we have a stride and not a stride multiplied (sm): type t integer :: i, j end type t type(t) :: x(5) print *, is_contiguous(x(:)) ! Shall be (and is) true print *, is_contiguous(x(:)%i) ! Shall be false - but prints "true". end The fortran-devel solution would be to use: sm == TYPE_SIZE(a%i). The trunk solution is to compare the array spec's object "a" with the the type-size of "a%i" - and if it differs to abort. d) The gfc_is_simply_contiguous function needs to be refined and extended - and a "gfc_is_simply_noncontiguous" has to be added. e) More tests are needed - including polymorphic arrays and compile-time checks for the code in simplify.c. [Which is related to (d).] f) For TS29113, one needs to handle assumed-rank arrays, including rank-1 ones. Again the question is whether the dummy argument associated with a scalar is then contiguous or not.