From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2951 invoked by alias); 13 Jan 2012 11:44:24 -0000 Received: (qmail 2941 invoked by uid 22791); 13 Jan 2012 11:44:23 -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; Fri, 13 Jan 2012 11:44:10 +0000 From: "jb at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/51842] fortran fails if ssize_t is 32-bit on 64-bit host Date: Fri, 13 Jan 2012 11:51: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: jb 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-01/txt/msg01499.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51842 --- Comment #7 from Janne Blomqvist 2012-01-13 11:44:05 UTC --- (In reply to comment #6) > (In reply to comment #5) > > Yes, and no. It is perhaps a better match for the current frontend logic of > > choosing a type equal to the pointer size, but semantically ptrdiff_t is the > > better choice for array indexing. > > OK. But then the logical step is to change the FE Yes. I didn't do it as part of my patch back in April last year, because I wasn't sure how to properly do it, and I didn't worry about supporting targets where sizeof(void*) != sizeof(ptrdiff_t). > - how about something like > the following? > > --- a/gcc/fortran/trans-types.c > +++ b/gcc/fortran/trans-types.c > @@ -576,10 +576,7 @@ gfc_init_kinds (void) > gfc_default_character_kind = gfc_character_kinds[0].kind; > gfc_character_storage_size = gfc_default_character_kind * 8; > > - /* Choose the integer kind the same size as "void*" for our index kind. */ > - gfc_index_integer_kind = POINTER_SIZE / 8; > - /* Pick a kind the same size as the C "int" type. */ > - gfc_c_int_kind = INT_TYPE_SIZE / 8; > + gfc_index_integer_kind = get_int_kind_from_name (PTRDIFF_TYPE); (Well, you probably don't want to remove the assignment to gfc_c_int_kind.) But otherwise, if this works, it looks ok. FWIW in c-family/c-common.c there is ptrdiff_type_node = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE))); So if the above patch + our definition for the array index type node gfc_array_index_type = gfc_get_int_type (gfc_index_integer_kind); accomplishes the same thing, it looks Ok.