From patchwork Tue Sep 7 13:33:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 64011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B8FE2B6F07 for ; Tue, 7 Sep 2010 23:52:50 +1000 (EST) Received: (qmail 21547 invoked by alias); 7 Sep 2010 13:35:34 -0000 Received: (qmail 21240 invoked by uid 22791); 7 Sep 2010 13:35:15 -0000 X-SWARE-Spam-Status: No, hits=3.0 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_NONE, RCVD_IN_JMF_BL, SPF_NEUTRAL, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp21.services.sfr.fr (HELO smtp21.services.sfr.fr) (93.17.128.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Sep 2010 13:34:55 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2108.sfr.fr (SMTP Server) with ESMTP id D4C8A70000A3; Tue, 7 Sep 2010 15:34:46 +0200 (CEST) Received: from gimli.local (122.183.72-86.rev.gaoland.net [86.72.183.122]) by msfrf2108.sfr.fr (SMTP Server) with ESMTP id D4469700009C; Tue, 7 Sep 2010 15:34:45 +0200 (CEST) X-SFR-UUID: 20100907133445869.D4469700009C@msfrf2108.sfr.fr Message-ID: <4C863F33.2040000@sfr.fr> Date: Tue, 07 Sep 2010 15:33:39 +0200 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; fr-FR; rv:1.9.1.11) Gecko/20100725 Thunderbird/3.0.6 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [Patch, fortran] PR 45564 ICE: type mismatch with bounds checking. X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello, this is the fix for pr45564 where an expression's string length had type gfc_index_type_node instead of gfc_charlen_type_node, triggering an assert in the middle-end (on 64 bits platforms at least). The fix is to add the conversion (second hunk in trans-intrinsic.c). Other hunks are about cases (noticed while debugging the ICE) where we use integer_one_node for string length, thus hardcoding string length type to 32 bits integer instead of using gfc_charlen_type_node. I plan to commit under the obvious rule once regression test finishes. Mikael 2010-09-07 Mikael Morin * trans-stmt.c (gfc_trans_character_select): Be conversion-safe while checking string length value. * trans-intrinsic.c (gfc_conv_intrinsic_char): Build integer using gfc_charlen_type_node type. PR fortran/45564 * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Convert string length to gfc_charlen_type_node. 2010-09-07 Mikael Morin * gfortran.dg/achar_4.f90: Enable bounds checking. Index: gfortran.dg/achar_4.f90 =================================================================== --- gfortran.dg/achar_4.f90 (révision 163944) +++ gfortran.dg/achar_4.f90 (copie de travail) @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-options "-fbounds-check" } ! Tests the fix for PR31257, in which achar caused an ICE because it had no ! charlen. ! Index: trans-stmt.c =================================================================== --- trans-stmt.c (révision 163944) +++ trans-stmt.c (copie de travail) @@ -1692,7 +1692,7 @@ gfc_trans_character_select (gfc_code *code) gfc_init_block (&body); /* Attempt to optimize length 1 selects. */ - if (expr1se.string_length == integer_one_node) + if (integer_onep (expr1se.string_length)) { for (d = cp; d; d = d->right) { Index: trans-intrinsic.c =================================================================== --- trans-intrinsic.c (révision 163944) +++ trans-intrinsic.c (copie de travail) @@ -1428,7 +1428,7 @@ gfc_conv_intrinsic_char (gfc_se * se, gfc_expr * e arg[0] = fold_build1_loc (input_location, NOP_EXPR, type, arg[0]); gfc_add_modify (&se->pre, var, arg[0]); se->expr = gfc_build_addr_expr (build_pointer_type (type), var); - se->string_length = integer_one_node; + se->string_length = build_int_cst (gfc_charlen_type_node, 1); } @@ -4709,7 +4709,7 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr se->expr = info->descriptor; if (expr->ts.type == BT_CHARACTER) - se->string_length = dest_word_len; + se->string_length = fold_convert (gfc_charlen_type_node, dest_word_len); return;