From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 119B2385781F for ; Fri, 20 Aug 2021 10:12:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 119B2385781F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-p4IOZHXaNTiVHFBMa5i1kQ-1; Fri, 20 Aug 2021 06:12:55 -0400 X-MC-Unique: p4IOZHXaNTiVHFBMa5i1kQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62BA5180FCA7; Fri, 20 Aug 2021 10:12:54 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.120]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E9715C1D0; Fri, 20 Aug 2021 10:12:53 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 17KACpx63076378 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 20 Aug 2021 12:12:52 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 17KACptM3076377; Fri, 20 Aug 2021 12:12:51 +0200 Date: Fri, 20 Aug 2021 12:12:51 +0200 From: Jakub Jelinek To: Harald Anlauf Cc: "H.J. Lu" , Tobias Burnus , Harald Anlauf via Gcc-patches , fortran Subject: Re: Re: [PATCH] PR fortran/100950 - ICE in output_constructor_regular_field, at varasm.c:5514 Message-ID: <20210820101251.GF2380545@tucnak> Reply-To: Jakub Jelinek References: <8d25c317-74fa-d8a2-724f-de6944fa602e@codesourcery.com> <20210820091618.GB2380545@tucnak> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2021 10:12:59 -0000 On Fri, Aug 20, 2021 at 11:45:33AM +0200, Harald Anlauf wrote: > Hi Jakob, > > thanks for the detailed explanation! > > > The other much easier but uglier option is to use a temporary buffer: > > char buffer[21]; > > sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, hwint_val); > > gfc_error ("... %s ...", ... buffer ...); > > This works, as it uses the host sprintf i.e. *printf family for which > > HOST_WIDE_INT_PRINT_DEC macro is designed. > > The attached followup patch implements this. > > Can anybody affected by current HEAD confirm that this fixes bootstrap? I have verified it fixes i686-linux bootstrap. But the new testcase doesn't trigger any of those new errors, is something else in the testsuite covering those or do you have some short snippet that could verify the errors work properly? > diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c > index 492867e12cb..eaabbffca4d 100644 > --- a/gcc/fortran/simplify.c > +++ b/gcc/fortran/simplify.c > @@ -4552,11 +4552,12 @@ substring_has_constant_len (gfc_expr *e) > > if (istart <= iend) > { > + char buffer[21]; > if (istart < 1) > { > - gfc_error ("Substring start index (" HOST_WIDE_INT_PRINT_DEC > - ") at %L below 1", > - istart, &ref->u.ss.start->where); > + sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, istart); > + gfc_error ("Substring start index (%s) at %L below 1", > + buffer, &ref->u.ss.start->where); > return false; > } > > @@ -4567,9 +4568,9 @@ substring_has_constant_len (gfc_expr *e) > length = gfc_mpz_get_hwi (ref->u.ss.length->length->value.integer); > if (iend > length) > { > - gfc_error ("Substring end index (" HOST_WIDE_INT_PRINT_DEC > - ") at %L exceeds string length", > - iend, &ref->u.ss.end->where); > + sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, iend); > + gfc_error ("Substring end index (%s) at %L exceeds string length", > + buffer, &ref->u.ss.end->where); > return false; > } > length = iend - istart + 1; Jakub