From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 4A79C3846401 for ; Fri, 19 Apr 2024 18:43:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A79C3846401 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4A79C3846401 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552214; cv=pass; b=GvaTsNBRNOGYVSLqrNFs4O7ipgwViPqHIESY4L0FSyXahEEiFKXTMROnHk15g9wuUdavNChfvBwrTbnZkvm0N8rJPek3DpsaOIdShBtI8OYTd0uXfE0fuUcVMZFBFXcCvbJBcC+lyMUrLH8uxIFysFFpGQVKEipNTeZMNBQyIv4= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552214; c=relaxed/simple; bh=WtEN/MUrHBro1GY5O/2ynDYvk9jNqi0t1s+oTrjcjgU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=xEZiFEjGxhhk6Lcbt8mUl5tlFHlkDUefIrHuNWwubvpvga6Eu5r3YFW+PF9H3vgVeyuNyhSgrYt5y2UMfGo+7kXaZmvWVn0szg5N+KK8Zzm11MSZ79gjGWHnXt2kiPI/13hXXVRxJr+uJ9c1hf23gVOq9C+9bA4hmXKuidGsua0= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JIOGig020853; Fri, 19 Apr 2024 18:43:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=SJHT7QevpUv0uILYCsx9tQQE2SszbQ86BtwMgNWKnLU=; b=O7dDD6QB8M9mOSIvT1lu/tPpkM9ISxcYEszNsUy+9ndjBSRr885SXxgu1g5zIoDqgckh +HmHrw1VLHNTfspOMbbCOtz4m1YkCcCsqM1V4cD5A95RHrpH9gUkbuZ5ahHGU85oF/bb Ral5BD+0bXesSiQnNc5r4RCyMZxuitwXaOjF7zDkR39fp5MjHjUvHQvE/88t//4Iq46z oL31oor84Fnv+KqGn7/5Ks5G5h4jIkW46qprdDsOxsMA29qQTj42ESVNwt8fXlBQBmvP caNledntkrYQ9lJCeM56uQhXjOnpkOgzdzNwfivut6V2lX7YCqlKbaEm3AUsD+7tNmms bA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfjkvdf9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:30 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43JHLAk2014319; Fri, 19 Apr 2024 18:43:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xkc97xrwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZKtvE6Md7dCh0XD7RQlILnK9u+MAs/59Zl2VtZhgQ34BEsTrLMafXgKgcPGsypxCRzX5ZFOKTioUq4z5bHZiWQd7j2q9q4epQB1lHbwuswwg88Vpx0w7yow45qMjygUVxhKXIFfqYJsHkcQaAg8jPmCgZ3JbLuLBdPlKMXw7txdC01jcb7YmGqPkyX2ZGvHRhKDauuuUhgWswYbw2TcVodhT5o7t5qDqnoYVSpQX0/hTdfz8pobJ7KAhkbFzWIFukNN4lpswPCTELMBgoJCRzoaF9qq2On5FG6pXbnXqX6tW1KHrksxO7fYnB894lbCa6oB55nE/h5R5SlAIsIvUUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SJHT7QevpUv0uILYCsx9tQQE2SszbQ86BtwMgNWKnLU=; b=mXQRfMGFP0nxcmSh8sJhs2+9e19QaH9NCiwbj6GjV4q9RFJDLU6qaBktBgKVkXWvAU5TYmPUI+JdDW6ml7OOCfN/uMGjLDqQF8WPUJQhEjNwEPSmF1W/yaShDNf3+se1b22wmtQGOx1m2SFw2OZ9CCGn3uBH7InZekgRt+Aj7TZfF2AShtY+fKrQ+vHNe7eX8xy7Dax4lEzUYoFCHptxefVrY38uWwSr7cRyXTezz1pa2Rt+EG1kdcPrX28J6QlHTXfeLJdUqoaEoxV4obQ0px8DvtRQLvkRk0J+BWjXVosB4r7PR7OBKWMnpWxgxqi+BY9SUA5K3sIOynIRtMQiWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SJHT7QevpUv0uILYCsx9tQQE2SszbQ86BtwMgNWKnLU=; b=c711rlIM5hOcJUO7XlsDXhAPOdrunyq/jj7Bf/2QvKc6k3AIQ4V8a8yZk//MYE/Rzw2NQd9WLxwz8fDv7ys6ckVYO4lS1E63//kuCFLteN464RwdxwH1YsS8rQ48krUlazdWYFA14lZbhFbiyq0r9kDi8kvepOqsmqOTHYRQUg4= Received: from CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) by DM4PR10MB7425.namprd10.prod.outlook.com (2603:10b6:8:180::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.43; Fri, 19 Apr 2024 18:43:24 +0000 Received: from CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc]) by CY8PR10MB6538.namprd10.prod.outlook.com ([fe80::2dae:7852:9563:b4bc%6]) with mapi id 15.20.7472.037; Fri, 19 Apr 2024 18:43:24 +0000 From: Qing Zhao To: josmyers@redhat.com, richard.guenther@gmail.com, uecker@tugraz.at Cc: siddhesh@gotplt.org, keescook@chromium.org, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [RFC][PATCH v1 1/4] Documentation change Date: Fri, 19 Apr 2024 18:43:14 +0000 Message-Id: <20240419184317.2138890-2-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240419184317.2138890-1-qing.zhao@oracle.com> References: <20240419184317.2138890-1-qing.zhao@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BL1PR13CA0130.namprd13.prod.outlook.com (2603:10b6:208:2bb::15) To CY8PR10MB6538.namprd10.prod.outlook.com (2603:10b6:930:5a::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB6538:EE_|DM4PR10MB7425:EE_ X-MS-Office365-Filtering-Correlation-Id: 009fcc19-7641-4b32-6951-08dc60a09844 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ia05A/xE204Z88EfoOydMGEalBlERCBlhBBVYYSxPvCsvXvPT91wdWXOgz9t7DLFlMkSqNMyMq00HMUbq6gZ6W3bd2gUMeIHPfjje+OeLJ7LBpCOyrjhTUCYJEYbYJTm5qLa/DOlZa+6p58vHilFBmaCvRJoawHWCEc7PSWs+HwDRl/NZpaytPLBLDfRqmYmPe6WtfrRf1HLETvJPNIzOjYmjjY9YzMYD+AY7blVOYHI72ILtcubK+hFnbmMNVvLNGjsPVCtmD8ATmRUXlKgT9Oo7nkrgVPikmzw37YAh6ZBouyRQIHKojiIhLXa3SuS1/dm2NJJ0NWsvxvKRELR566WNsuxQO3Fgc4uwqLNtuBUrHFTZ7q94VD8izNhz/dtY8VqTRY7jr8vEuV4Mo/WcYYKT92qGHUJLHFMgb7QvWqnggkujXHP0lemeY6+VKhuOUafuROpY8mUXaQ9vxwYPkKauZ5/BTvbla8bXvOobWYdhJ9sKoT5nEopZOv78mq8Ar9P8kfNMYqFqY7F/RhPJwtK3HJAiub9v5d145k633I7859iz93+DpSuJf8P9IEnFVTeQ4xn+PU33TldLi1RFPyKwly6z6hYlnxx8bq2NCTo+o651IYF+nLRKZ7PRo05S1oAQIxGknl8Ded2CYjDqG+N3ormyl+0v7HGadOO3b8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB6538.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?h/EEdZEAm52jMJGCwNZtHba7XVYUTyP9Uty5u0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iE1/iiezWOUkQOZwEb0EA2kBearm19B7Cyvv/v9gGR4gDz2UtXC?= =?us-ascii?Q?pNGCKB5OixyNJrSsbXKzH6DSA9ShXD+H1Pn6YZX8hLaKJG4wk4wvhmMkvAme?= =?us-ascii?Q?yaHHn16Ja/C0p1met1TsIhdKO8IfnFqR8Sc7dyr72mCk7S3ZsF8SLb5VayZh?= =?us-ascii?Q?AvYB0qjwNuoKunVv7kIcjCnZDQ4pstMJJkVApi3QGW/IqDJpVVyyGPlVvPka?= =?us-ascii?Q?u3PO3Nl/vklTe7JQoeopq6HuJcLwL5Yf0ASzymNqWOuRZOw3Bjn3x/gUYG8S?= =?us-ascii?Q?ksvlyo38eY65rV6sfnVaraJLMQlXatSlh9Bic35O4Hj6NARnk5W+GK1+o8+0?= =?us-ascii?Q?fzlmiDY8ahNHwfdfvhX1aYL1mk0KYu7gdW3WWrH19QS9rMU+p3y4pS2OMu6a?= =?us-ascii?Q?gtTHoGhAzT2P4CQP20viysDqM0kLKPD8i8Q3jFVhVWJU6vlSQiEuX4jaHA+m?= =?us-ascii?Q?35/TJ175GgbP8cTZ80xKXw/re8oWGB/5o1C5reN9Imv6vmXEaKDhu4PF7MBG?= =?us-ascii?Q?/W7SGPRUPQa1PBvozvUvugNww0AB/mBegeBtwidvW8eQMftvEXQJJx5YoIH1?= =?us-ascii?Q?A7xpDZsMSdIxmgB+lGJO7YsL7ocIyP/MjbCdMdbsmEYM1iDoVY17CJb4hE7A?= =?us-ascii?Q?lSaVSLtI6ic9RaFDpp6n9GfglDF/cxw+Ut913kqc?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: R2zsw8MZehyeI/tYUlFiA2gyi9CJlfxOqcfP6xuc/seYJ8GyBi31k7cDdS5niwg0Ul1cqNuAboXE+Szpj03I1ieMMLpIZvTZs5oLxS2s6p62RTQdpygQY7zKporJBWaV6HCerOyAeLLwCqAYsGhPT9O9TAu+bVpr68LRnwI0e62cyeXa1yj0ML7ZFIh2RCkSHtZX3uxpOyaQA3C9bwKlcGohfSXFziaOgtPkv7/SXiGKY5qFBn9t1hILsyesRy8P5R4F0vLK4F1trcHdTaEcfW5Ck1rzTebB95VdGizo7iBPzk86MliVlt4jCr/ronni/11KXQ2jCCfHbWgAQkqRpQYV0sQBhwhilJB6Mq9WAVAFXmB6/Ly0HDkTi4fsJ949CEiI0fZGyT2k1Q4uMsyBZI81/+UTxfwlkyDKuMizMkpaBjaHni7lbGbW6J4oelDUUdw8fa3ckneb2n7UAcrmGjpf2pK85nx+YcnUwipAm2856HzRX5jVa8vvkYAHWBC/gRy1eniZTG0k6EBlh/69mXiy98i3pnaR8nb4wu+A6cZQhOpCzlcdEKSnuDbe8tjigiJwu8Kz9u9XPn5smJU0ccjV1ILl7RvF3tPbS04fgFw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 009fcc19-7641-4b32-6951-08dc60a09844 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB6538.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 18:43:24.6477 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ua2a1yYasIRWuNm7pThv7pU4gbc46Cj4KzuZJfvhb3L3E7V3Vy8SIThpY/3cud4L4obNL2qCEPGGwHQX2gImYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB7425 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-19_13,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190144 X-Proofpoint-ORIG-GUID: UGULGOU1anGpsnCYsqS8zez7oJL6rpYU X-Proofpoint-GUID: UGULGOU1anGpsnCYsqS8zez7oJL6rpYU X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: for allow flexible array members in unions and alone in structures [PR53548] The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53548 However, this PR was closed as WONTFIX around 2015 due to the following reason: "there is an existing extension that makes the requested functionality possible" i.e GCC fully supported that the zero-length array can be in a union or alone in a structure for a long time. (though I didn't see any official documentation on such extension) It's reasonable to close PR53548 at that time since zero-length array extension can be used for such purpose. However, since GCC13, in order to improve the C/C++ security, we introduced -fstrict-flex-arrays=n to gradually eliminate the "fake flexible array" usages from C/C++ source code. As a result, zero-length arrays eventually will be replaced by C99 flexiable array member completely. Therefore, GCC needs to explicitly allow such extensions directly for C99 flexible arrays, since flexable array member in unions or alone in structs are common code patterns in active use by the Linux kernel (and other projects). For example, these do not error by default with GCC: union one { int a; int b[0]; }; union two { int a; struct { struct { } __empty; int b[]; }; }; But these do: union three { int a; int b[]; }; struct four { int b[]; } Clang has supported such extensions since March, 2024 https://github.com/llvm/llvm-project/pull/84428 GCC should also support such extensions. This will allow for a seamless transition for code bases away from zero-length arrays without losing existing code patterns. gcc/ChangeLog: * doc/extend.texi: Add documentation for Flexible Array Members in Unions and Flexible Array Members alone in Structures. --- gcc/doc/extend.texi | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7b54a241a7bf..b12ce5fb9b87 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -42,6 +42,8 @@ extensions, accepted by GCC in C90 mode and in C++. * Named Address Spaces::Named address spaces. * Zero Length:: Zero-length arrays. * Empty Structures:: Structures with no members. +* Flexible Array Members in Unions:: Unions with Flexible Array Members. +* Flexible Array Members alone in Structures:: Structures with only Flexible Array Members. * Variable Length:: Arrays whose length is computed at run time. * Variadic Macros:: Macros with a variable number of arguments. * Escaped Newlines:: Slightly looser rules for escaped newlines. @@ -1873,6 +1875,41 @@ The structure has size zero. In C++, empty structures are part of the language. G++ treats empty structures as if they had a single member of type @code{char}. +@node Flexible Array Members in Unions +@section Unions with Flexible Array Members +@cindex unions with flexible array members +@cindex unions with FAMs + +GCC permits a C99 flexible array member (FAM) to be in a union: + +@smallexample +union with_fam @{ + int a; + int b[]; +@}; +@end smallexample + +The size of the union is as if the flexiable array member were omitted +except that it may have more trailing padding than the omission would imply. + +If all the members of a union are flexiable array member, the size of +such union is zero. + +@node Flexible Array Members alone in Structures +@section Structures with only Flexible Array Members +@cindex structures with only flexible array members +@cindex structures with only FAMs + +GCC permits a C99 flexible array member (FAM) to be alone in a structure: + +@smallexample +struct only_fam @{ + int b[]; +@}; +@end smallexample + +The size of such structure gives the size zero. + @node Variable Length @section Arrays of Variable Length @cindex variable-length arrays -- 2.31.1