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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4B2D93858D39 for ; Tue, 28 Feb 2023 17:49:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B2D93858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677606566; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=9cXweCYOE5UtxkhH+NJfq3Kh/FrikyIEekSS6h0N9hE=; b=bnoRV/8tPTLCOdbVOFtREN3g4yCbxZGnSSWfgSUgd7p2IzU9e922/ZOwr1av+TBQFV4atk p31cir+xEbwoAE0fJ/hLIhqH6bC6GPSfVyP/ZYOMtnhYDiBBUq35dIQnlg4UPXMuGsm2mp HblzjGxpVuF0Gdf2QrXJxUSuPJ9kJNI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-tPebtxI8NFSrru7S4vrlew-1; Tue, 28 Feb 2023 12:49:25 -0500 X-MC-Unique: tPebtxI8NFSrru7S4vrlew-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13B5D100F908; Tue, 28 Feb 2023 17:49:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.101]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAF7A492B0E; Tue, 28 Feb 2023 17:49:24 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31SHnMNe3322200 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 28 Feb 2023 18:49:22 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31SHnLvd3322199; Tue, 28 Feb 2023 18:49:21 +0100 Date: Tue, 28 Feb 2023 18:49:20 +0100 From: Jakub Jelinek To: Qing Zhao Cc: Richard Biener , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH] ubsan: Honor -fstrict-flex-arrays= in -fsanitize=bounds [PR108894] Message-ID: Reply-To: Jakub Jelinek References: <50C5DFA0-F8A5-4E1A-8353-FBF3CABF3F4B@oracle.com> MIME-Version: 1.0 In-Reply-To: <50C5DFA0-F8A5-4E1A-8353-FBF3CABF3F4B@oracle.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Feb 28, 2023 at 04:13:28PM +0000, Qing Zhao wrote: > > On Feb 28, 2023, at 3:26 AM, Jakub Jelinek via Gcc-patches wrote: > > I think -fstrict-flex-arrays* options can be considered as language > > mode changing options, by default flexible member-like arrays are > > handled like flexible arrays, but that option can change the set of > > the arrays which are treated like that. So, -fsanitize=bounds should > > change with that on what is considered acceptable and what isn't. > > While -fsanitize=bounds-strict should reject them all always to > > continue previous behavior. > > > As my understanding, without your current patch, the current -fsanitize=bounds-strict behaves like -fstrict-flex-arrays=2, i.e: > it treats: > [], [0] as flexible array members; > but > [1], [4] as regular arrays Yes, but not because it would be an intention, but because of a bug it actually never instrumented [0] arrays. Well, it would complain about struct S { int a; int b[0]; int c; } s; ... &s.b[1] ... for C++, but not for C. > Then with your current patch, [0] will NOT be treated as flexible array members by default anymore, so, the -fsanitize=bounds-strict will > treats: > [] as flexible array members; > but > [0], [1], [4] as regular arrays > The same behavior as -fstrict-flex-arrays=3. > > Therefore, -fsanitize=bounds-strict already implies -fstrict-flex-arrays=3. No. -fsanitize=bounds-strict doesn't imply anything for flag_strict_flex_arrays, it for the bounds sanitization decisions behaves as if -fstrict-flex-arrays=3. > For [0] arrays, why C++ and C represent with different IR? I think it is a historic difference that could take quite a big amount of work to get rid of (and the question is what is better), and even after that work there would be still big chances of regressions. Jakub