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 083943849ACF for ; Fri, 19 Apr 2024 18:43:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 083943849ACF 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 083943849ACF 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=1713552208; cv=pass; b=N1YAumcGQr1bYyKObH0feUHOQkcQMYnJOvLKlqMjmq5agYS+imjBTjw3FIEBxhlA0nIY2bCpCL/fGvoQdD3bx1WzR4NWyxw6AIPYGJSL9L30VfkDr9K3Orhl66sCpioIhMOEEtGjcHRf2K9h+Wu4TKrocahTcej41LtwLYxz0l4= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713552208; c=relaxed/simple; bh=XDttVXZH+EbfMsZtgc45wOTlPqfbplxZ0LOC0IJlZOs=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=Sp3HPz8bFCLq2TfZr6fDbCgsMWET9L71bK6Ls2OR2RM7F4Ih3BLkV+SBWRFeFL7TJbqHE9XTupV7k53G5Tn7Ou6W8Yrfu5yF9ad3tZKeiVAngmgcj5bUPWG6yVI3QBEofZKd8Re6hx06LdS5ak7tz9lQsrOWfDyZnp9JkCoI6yE= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43JIO5qJ013481; Fri, 19 Apr 2024 18:43:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=k2/ZrB2x9U+UpMuZB9edpezyYSl26EyfKXpwrlfhGeQ=; b=GHQzUZk44p0NUJe7e6NlKDyhTyIl9+jrh2BUuFd9yl1Thtk5QY7wANIr78T0jsCM3/0i U9XCTckxTneawmd6p5HmytCkFgEu/JhJH39CQ7IE8Ko6G7cqNMZoYpyyBMXPW4T7AQny o5WX6KsJLsjp9/kfk4r4nagVUJJJNe2bH42Ww+146kB+PySgNg7TaO0rdXlcrCbVQkLs R24/8Nm7WZBXeuT2Wch4k6N+br5sddYK2q2bMNd7xUSMOd4HdhpSGXx9WrqkWLVcw7Wc vSDe2A6ukYYkdYQRpE3xqiP8uSC3bGZyWVJOY0vW4flHkqfaiSKExB2uG1cEZu2PownT +w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfgn2whb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:24 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43JILc7E016900; Fri, 19 Apr 2024 18:43:23 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xkbjcguar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Apr 2024 18:43:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i8L/B3RP4pkaKx9bK9qP77HizwmWwpbQ5CS8KbJrlu9qXeOnUbNLpfsi8oj2KN6eF9O8TSGTpiOWcplq7o9yMF8SlUYXIbH4IQt1zmOHIdGKt9q0sUjl/+zrlLSFrOnHGVC8iaMkOxx103xntAj7Wi5A4TELY2RLqRypLOGBiOyjipl8zUp3M6FAKybFWKiTQoHy0/86Oq8pJ5S79h+Ba3wv09bB6ej3vqal92wlp+3481SLIbv3/mB4RE9t+LWzjOanv7dC4xFXZ1PmAxZCiml0g8XmmGNzrI9tSpLuco+PzUy3BxQfj/sC2aiZRN/7bCgcWqJ+M5mI9QzwSBTKvg== 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=k2/ZrB2x9U+UpMuZB9edpezyYSl26EyfKXpwrlfhGeQ=; b=UONBMHn08+JcLJ5o5ezVikqXpoyYc2kUsm2iGFVOcaiZsai/Yc+RBTMfQ4IWlr9RcURKiK2WugX34lh/QPfS0Akl0VZrmp1MDawGCI/fNOafzo5IAZWogrSjn60vg/3Xiq18FXs71wBJxU7tGE644coXR7wXAhkae+YJZvbOSXgfG4kGBNt3kmNTxtNBVypfTMn90Qb+LiPf897GuzjM26YMfqyZ4zsOeHpqXHf5uIdlY77Dtqn+8MKUJUOBk93c9RNX+b493Mkh7x29zd0FpyQ9XFVkkfBCyzChxCmoiLi0BxH/pEEXSBIA8FEbvxyZzTpEFoIzZu/Y91RLhmkNfg== 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=k2/ZrB2x9U+UpMuZB9edpezyYSl26EyfKXpwrlfhGeQ=; b=jsGjEKKxeNEZ00JR1048q64fsD4MRxFhUAyXFnrgl3jUZ31jApHjKaB7uOdfrWoriOrHq7fohGxYb707eFJi2Er93g5HDfp3V83f5gajBaZsy9p8mErVp1NWTs2nyt0I7G8iAZE5etOXh/UxipTeH5C/VR8Dd95USiFCu2LJaRU= 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:21 +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:20 +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 0/4] Allow flexible array members in unions and alone in structures [PR53548] Date: Fri, 19 Apr 2024 18:43:13 +0000 Message-Id: <20240419184317.2138890-1-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BL1PR13CA0132.namprd13.prod.outlook.com (2603:10b6:208:2bb::17) 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: 742d57da-edd8-43e6-ba10-08dc60a095f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +lajyOATtgIfkaqT8kWTUrGXIJS8KrRTA5dKfhCknJpV2p7Vtq9MbdAowN/goF98PDgUU/seBKPYqyGUSSK+R6cCNMaB254CyiZUZVGcZ5q7Y5qdxoZXMKw68t9M9wMLke9ksCzi0/Je0TfwfGL/b97uIKHpxCq0XGKlN0s2dikw26+ylxokeTj3SD4i6sjTQtTldvLCYd0wdZcGZCqHDiEqjdX4KrIE3gkwz45UWnuUdiB9nc3KabUnjdE96xHgQMr69ffzlbYaQz1arJpz3tovb2Ne0CuqCmAIzXdkp01EocbIaJdnue7wy4p0qAH7tPspIZbPo7hbhcexVilrkZToVUmqdjYq+q46QWI1g40pI2VDREN5MBbXZ6r4disxDXe1u2J8hQbkKBeeFJ+gXuRYIl0KJvwFqZOyIkGjY7WbXGBTxigbYPQ/yK0FxEvxtpusafTUZmLIMZbv9iltrTkykEu3LM2/DZXHmR6zlGL6dEMFLEUn9YYyyUjyXHCG+MCxiS1lcHLqUQTTPnmcLHLFfIiwHZx5rUTBUgRfds/pENkLHJUnQ+TTyJOB5UfE+lD02VUiuzmIRHHEkNjAMcU+FHIaSp1pXzBsTg0O8S4HSOGndkGuFTYug1FJWJuPiK+I5mHK0dQnt+XnQkIKh4H6dcd/WP+NGoRJkI1fuCs= 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?2Hp2p6tEHX9RpnnNvDC1DV0yRhB5dMu3N/kxBDitpKbl99irocNTf5/v7A4f?= =?us-ascii?Q?BDmhYhuhfJm1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1orj?= =?us-ascii?Q?WHB7Ir86aBFvOtksbYQgMWxD5/y5XKd/PpNqL/C/EofaMOo1MhwR0yWhDLCP?= =?us-ascii?Q?i+MDIyMXkAfXNdVrdY6O6mN6M5vg6tb4MgQUgb4727HAN0Jhu3C1sW+/Eu//?= =?us-ascii?Q?GNRx8yxD+/O3taDlerdkB28JF4hMhM5NqjaQsBM90oys0IsOei7NsvsUQnHh?= =?us-ascii?Q?9mbzB1mlmM+wZD5lsx2xPd05DMz1Az3Y0Bron9k5h8VSL5FXh79fg8WY+Xq/?= =?us-ascii?Q?ByW+zHM7E1KBTxcvfbMRBzpIWm2IgsBgdb1IdEG0VrSypQXGb6kqoYNHwe7X?= =?us-ascii?Q?f2YNcjQfPGGVLF6utDFmR9hSGjMxer0AVjBqoaD61A2EW/2jy9WOraxaac8m?= =?us-ascii?Q?plvA/tfgjc5WW+SgiOjA7cma1oI7RJOHZ+hOFaDyfmqULGcyDHYheaKKgvjm?= =?us-ascii?Q?Y43aITmhFjqPXrwQ3lTxyhGO0BfINrfxVmyXuK5fzlTAMJb/Xvri41e/ViwU?= =?us-ascii?Q?EK4bwmmcANb48f4JMWlCR8exOJoUb3/36RBpX/8ZlGcorfR7l5zgPuHjpf/+?= =?us-ascii?Q?r34BUsNovtvMpXmLZc57tgLx6WSwFZASf1cG0KlrhmW8m9BT0jjudq3vsd0e?= =?us-ascii?Q?jTQdbbgpiXLtDISNwfF+393C/1tRw4hLlgQQA164?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: lNU1azzF3GknRLu6nmtetMdcMgRHiYwYVdYM3ikI5B4yJzqOgf/AZaGRFYWg5tkcBacdKk3m1xejSrUkJAJb2ULvvEAc1YcMQTw+Xt+mOoj6Z/UFnrELKYjvUEvkMiiZ+cr1vqCLq6n2AKOyqoztxumclTAEMS3vMy3E/hQFeKHzkvjNjfw+AVUiChv9vEPyzMNkkIS+5zsokKuWv/rPY+olkxxn/IcBn+wyEW0DqRIuL4fSaCcK/zEMRUQihI2GGT0r+FvTuFyxsiR9YVyXvJgHOBhvFdYGHsXSp9ehwdu2CnpPMkcr3dNg7dyIijpAF0q69OuTA/UDJ0dRxWvpDMZQ61fcSKx+aE2MKzHIb7k1Y+WAyblO6ZpDIwzDPlKw71tFzgZC1/UrevRDPwp08TJqGCEJPxjriRhlEJk9dJo6xJqKASL/NGz8XSHF/KAqNPfvrCseh7DjLM8xPcZ4q6tA66xKEulM4V9KJ/npzNwrgbE0ccfr3L5pnwMI2/+sOm20Nj+kd2VwcG8J/LvXUAwBrfCaR1oi8P2qwcBer6AHytohexAVmyickED0AJyvI+KK8tFg0Gozueee9x57XTqk/M+VXMFd0Fm7huqQnLY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 742d57da-edd8-43e6-ba10-08dc60a095f1 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:20.7809 (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: /GoRF+usTlZLUXnIxSrJIEwUqIEfPgm2MuEXCvUbqG2GqpDqdK/gQsw87RWuslNqDWbKiPNX+qEstN8IMS0jUQ== 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 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404190144 X-Proofpoint-ORIG-GUID: XHzw-7pfwvqeTjafgruZNPTInyBLK7gA X-Proofpoint-GUID: XHzw-7pfwvqeTjafgruZNPTInyBLK7gA X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: Hi, The request for GCC to accept that the C99 flexible array member can be in a union or alone in a struct 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 union or alone in structs 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-lenghth 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. The patch set includes: 1. Documentation change. Allow flexible array members in unions and alone in structures [PR53548] 2. C and C++ FE changes to support flexible array members in unions and alone in structures. 3. Add testing cases for flexible array members in unions and alone in structures. 4. Adjust testcases for flexible array member in union and alone in structure extension.