From patchwork Sat Jan 14 08:39:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janne Blomqvist X-Patchwork-Id: 715329 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v0tGK0x2Hz9t2D for ; Sat, 14 Jan 2017 19:39:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CAeQH8dG"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; q=dns; s= default; b=gkiYtGkKR5blQstAKo8CWht83Slv6WAplXjkNT+8PXMe/9NyvZFj5 EXRVYASaViNiZsb8mVEEguoBupXavsHcdd1fsXzuKPtLq00C0Qd++6mMHbJV+L0W s4ERB/wA0cOo63XePFiuzTLYWIDlHvbZ/4mXhFYpEGZzN2b0FGxFAk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; s= default; bh=gsALlfP4UALslrdDm1Oq5PbtKKk=; b=CAeQH8dGE3wvlT3Mtxes 0X74PwL9bOVl3W4YeABxwR8oJj8t8KfDEsS11pJMHBDK2QI2wtUkpfBlKEqN/VLZ Ms4FzGQD/4/lgRVWIg/CaJt3vfff+6ruoSc03e/5QRK0/TYNA2OI0Hh4XLdgwL50 xq9tFvjB3zek8AGfPGIMlao= Received: (qmail 59214 invoked by alias); 14 Jan 2017 08:39:27 -0000 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 Received: (qmail 59191 invoked by uid 89); 14 Jan 2017 08:39:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:dominiq, D*lps.ens.fr, KIND, dominiqlpsensfr X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yb0-f179.google.com Received: from mail-yb0-f179.google.com (HELO mail-yb0-f179.google.com) (209.85.213.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 14 Jan 2017 08:39:15 +0000 Received: by mail-yb0-f179.google.com with SMTP id w194so17964155ybe.0; Sat, 14 Jan 2017 00:39:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=xKjArKXLzVT0ToZc9bP9avRyal4KJ7kZeTDea/2xVDk=; b=ZBFkE+DZOTV3cshCb/i5yvw+5BKDF1fQmeJFY0idXqlNo9osXK429pOXIZMQOV4lNU ofsN0HLPuLOscSxtLgjc8+haguRppq7ZDcQElCbrBzuPHn1DlqwK8bz5MeR1sXG/4AFi pu3NBK28CPpIAAQlJyrNVTZYVgQUiLfk1Zjd4FjQV+f+JKGUWneh9Uw+qZRAlwpGNPHS vRN3mVeHWdHf0gsjAl3dPILSCIG8TRS2bdBbW7gyvmOcLh2l9gX3ViiOi1GC5pgxPRjo dD0kRQVkkIkXgVYOqhSarvXVcFcbIqFGNKtMh6oHNKecde1qHJJAbj+QXZszmtH/kspT 7mHw== X-Gm-Message-State: AIkVDXKPC7JyM4O51t4VMIOCv5yWm5/kd3KSRdspAddpXvrpTGK7Y0MYnuGBbi0kI+mhBHObyaq1EU7SuMYZ0g== X-Received: by 10.37.5.134 with SMTP id 128mr7531990ybf.1.1484383154184; Sat, 14 Jan 2017 00:39:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.207.151 with HTTP; Sat, 14 Jan 2017 00:39:13 -0800 (PST) In-Reply-To: <60948DB4-4A24-4836-85B4-66F422215080@lps.ens.fr> References: <60948DB4-4A24-4836-85B4-66F422215080@lps.ens.fr> From: Janne Blomqvist Date: Sat, 14 Jan 2017 10:39:13 +0200 Message-ID: Subject: Re: [PATCH] PR 78534 Change character length from int to size_t To: =?UTF-8?Q?Dominique_d=27Humi=C3=A8res?= Cc: GCC-Fortran-ML , GCC-Patches-ML On Sun, Jan 8, 2017 at 4:29 PM, Dominique d'Humières wrote: >> r244027 reverts r244011. Sorry for the breakage. It seems to affect >> all i686 as well in addition to power, maybe all 32-bit hosts. > > For the record, I see the following failures with an instrumented r244026 (as in pr78672) > > FAIL: gfortran.dg/char_length_20.f90 -O* execution test > FAIL: gfortran.dg/char_length_21.f90 -O* execution test > FAIL: gfortran.dg/repeat_2.f90 -O1 execution test > … > FAIL: gfortran.dg/repeat_2.f90 -Os execution test > FAIL: gfortran.dg/widechar_6.f90 -O1 execution test > … > FAIL: gfortran.dg/widechar_6.f90 -Os execution test > FAIL: gfortran.dg/widechar_intrinsics_6.f90 -O* execution test > > The run time failures are all of the kind Sorry, I missed that I had to use an instrumented build to catch these, and assumed everything was Ok once I managed to regtest cleanly on i686. The following patch fixes these issues for me, does it work for you? #endif diff --git a/libgfortran/intrinsics/string_intrinsics_inc.c b/libgfortran/intrinsics/string_intrinsics_inc.c index 0da5130..74a994b 100644 --- a/libgfortran/intrinsics/string_intrinsics_inc.c +++ b/libgfortran/intrinsics/string_intrinsics_inc.c @@ -177,23 +177,25 @@ string_trim (gfc_charlen_type *len, CHARTYPE **dest, gfc_charlen_type slen, gfc_charlen_type string_len_trim (gfc_charlen_type len, const CHARTYPE *s) { - const gfc_charlen_type long_len = (gfc_charlen_type) sizeof (unsigned long); - gfc_charlen_type i; + if (len <= 0) + return 0; + + const size_t long_len = sizeof (unsigned long); - i = len - 1; + size_t i = len - 1; /* If we've got the standard (KIND=1) character type, we scan the string in long word chunks to speed it up (until a long word is hit that does not consist of ' 's). */ if (sizeof (CHARTYPE) == 1 && i >= long_len) { - int starting; + size_t starting; unsigned long blank_longword; /* Handle the first characters until we're aligned on a long word boundary. Actually, s + i + 1 must be properly aligned, because s + i will be the last byte of a long word read. */ - starting = ((unsigned long) + starting = ( #ifdef __INTPTR_TYPE__ (__INTPTR_TYPE__)