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.133.124]) by sourceware.org (Postfix) with ESMTPS id 2AA643858C36 for ; Mon, 27 Mar 2023 16:06:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AA643858C36 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=1679933190; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PkXjgVynuZu0WszSrsoOuU0ntbwjEiiPJu8EgIh9DB0=; b=T1kMWQm9KhU7NW4HoBrpSuGod5KGxUY8AGgRsty0oj0oFx5iuKgBY/U8gPqz9i1DKiW1pM YmJm8THrpPn5YPZ7yViSztdugRGyhanSd814K036bdndUIEitLmcdJYQfwxU8U/wtjA2H3 ohr0ufjzD6mSmjTIG2MpoL24W2CkTwY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-3Nm18ERHPBGTh4t6Yi4RpA-1; Mon, 27 Mar 2023 12:06:22 -0400 X-MC-Unique: 3Nm18ERHPBGTh4t6Yi4RpA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0055A1C12983; Mon, 27 Mar 2023 16:06:22 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A15641121330; Mon, 27 Mar 2023 16:06:21 +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 32RG6IiH3453629 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 18:06:18 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32RG6GbA3453628; Mon, 27 Mar 2023 18:06:16 +0200 Date: Mon, 27 Mar 2023 18:06:16 +0200 From: Jakub Jelinek To: Qing Zhao Cc: Joseph Myers , "sandra@codesourcery.com" , Siddhesh Poyarekar , Kees Cook , Richard Biener , gcc Patches Subject: Re: [V5][PATCH 2/2] Update documentation to clarify a GCC extension Message-ID: Reply-To: Jakub Jelinek References: <20230316214715.604671-3-qing.zhao@oracle.com> <4a128885-687d-9c22-778-811816b2e535@codesourcery.com> <236135FA-D551-4C19-8324-2DD6E80C9E38@oracle.com> MIME-Version: 1.0 In-Reply-To: <236135FA-D551-4C19-8324-2DD6E80C9E38@oracle.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,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 Mon, Mar 27, 2023 at 03:57:58PM +0000, Qing Zhao wrote: > >> +Please use warning option @option{-Wgnu-variable-sized-type-not-at-end} to > > This is certainly misnamed. > > The name “-Wgnu-variable-sized-type-not-at-end” was just used the warning name from CLANG. -:) > > Shall we use the same name as CLANG? Or we invent a new name? The latter IMHO. Having a warning with completely nonsensical name will just confuse users. > > GNU variable sized type not at the end of a > > struct is something like > > void bar (void *); > > void foo (int n) { > > struct S { int a; int b[n]; int c; } s; > > s.a = 1; > > __builtin_memset (s.b, 0, sizeof (s.b)); > > s.c = 3; > > bar (&s); > > } > > Certainly not flexible array members in the middle of structure. > > Right now, with -Wpedantic, we have the following warning for the above small case: > > t2.c:3:24: warning: a member of a structure or union cannot have a variably modified type [-Wpedantic] > 3 | struct S { int a; int b[n]; int c; } s; > | ^ Sure, it is a GNU C extension (not allowed in C++ BTW). It is documented in https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html though just very briefly: As an extension, GCC accepts variable-length arrays as a member of a structure or a union. For example: void foo (int n) { struct S { int x[n]; }; } > Do we have a definition for “GNU variable sized type” now? Naturally, variable sized type should have non-constant sizeof, because otherwise it is constant sized type. That is not the case for flexible array members, there is nothing variable sized on them, especially if they are in the middle of a structure. Jakub