From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65409 invoked by alias); 12 Aug 2019 13:40:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 65176 invoked by uid 89); 12 Aug 2019 13:40:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1129, H*f:sk:80cf0a2, hack, H*f:sk:0e9e903 X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Aug 2019 13:40:42 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3870BAD4E; Mon, 12 Aug 2019 13:40:40 +0000 (UTC) Date: Mon, 12 Aug 2019 13:56:00 -0000 From: Michael Matz To: Martin Sebor cc: Jakub Jelinek , gcc-patches Subject: Re: [PATCH] fold more string comparison with known result (PR 90879) In-Reply-To: <0e9e9034-3357-6d8e-d38d-35c38bdb2882@gmail.com> Message-ID: References: <223e6275-98b9-f46d-a5c0-4ea802a68aaf@gmail.com> <20190809162257.GB2726@tucnak> <80cf0a28-35c9-d57f-729a-d1cf58bd21d1@gmail.com> <20190809165803.GC2726@tucnak> <0e9e9034-3357-6d8e-d38d-35c38bdb2882@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00739.txt.bz2 Hi, On Fri, 9 Aug 2019, Martin Sebor wrote: > The solution introduced in C99 is a flexible array. C++ > compilers usually support it as well. Those that don't are > likely to support the zero-length array (even Visual C++ does). > If there's a chance that some don't support either do you really > think it's safe to assume they will do something sane with > the [1] hack? As the [1] "hack" is the traditional pre-C99 (and C++) idiom to implement flexible trailing char arrays, yes, I do expect all existing (and not any more existing) compilers to do the obvious and sane thing with it. IOW: it's more portable in practice than our documented zero-length extension. And that's what matters for the things compiled by the host compiler. Without requiring C99 (which would be a different discussion) and a non-existing C++ standard we can't write this code (in this form) in a standard conforming way, no matter what we wish for. Hence it seems prudent to use the most portable variant of all the non-standard ways, the trailing [1] array. Ciao, Michael.