From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nUlyq-0001yL-SY for mharc-grub-devel@gnu.org; Thu, 17 Mar 2022 04:59:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlyp-0001vb-In for grub-devel@gnu.org; Thu, 17 Mar 2022 04:59:35 -0400 Received: from de-smtp-delivery-102.mimecast.com ([194.104.109.102]:46486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUlym-0002MA-FC for grub-devel@gnu.org; Thu, 17 Mar 2022 04:59:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1647507568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JGuRtJLdg0gAtl9mqZK6ob9EBIwgC+x5jjixkiYEW5c=; b=aIIgy3Aw0PFhUvwFVZYrpgdU8xP0P8rELSUgjGkEc9EBRp2NxHlkSJ1eilBOJel2ntTyd4 Qq3rVWgL7f7R/n9k57gf+xMAzH6h5im1vSUyRveGx6IhZh+aGxj1CGUYGOfTKNRCMyz5JT 9KrNWF/NvSiOXIhZ5ULSWE11MPvxnIc= Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01lp2059.outbound.protection.outlook.com [104.47.1.59]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-29-Ui7Vd4QmObmBUxCI6T47cA-1; Thu, 17 Mar 2022 09:59:27 +0100 X-MC-Unique: Ui7Vd4QmObmBUxCI6T47cA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WtF4SUPcPcYhMokFKFIaHxk66oJJHifE41Gxz6SGzFMiTjHP1eHRYqB4lfSEhAw+rI5m+/KEV7genD2I0xnNpdCIkgyhWPVwyT06Hwcj18/A/O9jE+HVKFtcDaAAVBj5TzxtpIFKCcVXVFXTiKinpzDPzPEQOTznd0sNLpBaR6x1+wqgisO3/HkSbzYGCElcuiXX34EuzJVCIy1C9uolS3aHR0u8ytuaUU541xAtZYG5B9njOS3Pt3sn8WmKwK/2qSJv6d0c+R0BoGa7lq2e0I+YMcF0CFFodCZKJPB1pvetlFFohP4TzdN7QkoCpJAkpsJfQegLCnmtTcn1xVKgCQ== 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=JGuRtJLdg0gAtl9mqZK6ob9EBIwgC+x5jjixkiYEW5c=; b=nQqKq+JJmjsjiYc9JEb2BNs3kUyKg3EMDK+zoENjJffZ3Si+ryNqA4zffa+IPSe0d87jVsUZh5roQLgU3ox1txQH9uty3CmxNOEB+Cdt0DSAtmFcyCby1cBR6O628MFj3ibiYItCfR9usUwzhRt0/wu7zHuHjwHhiP7mSjrLnRQH5mV5rtOZI4pzmtYPW4iGASBaEkkpI0xVYUuH1ZMBMerZkvsoLHI7/WuNvDj9DftZ3I1XSsef3BB15YqWTIVLSYGc9JgdJVfS7CZpKjK0mG9Umh0KcWi1bx0dxOxm/Qx5tpFCT8ks22Zffj2VCknn0ATKMb0JjE8Y81DFMznVbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DU2PR04MB9081.eurprd04.prod.outlook.com (2603:10a6:10:2f0::13) by AM0PR0402MB3858.eurprd04.prod.outlook.com (2603:10a6:208:f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.17; Thu, 17 Mar 2022 08:59:25 +0000 Received: from DU2PR04MB9081.eurprd04.prod.outlook.com ([fe80::2d29:445:cc37:a97f]) by DU2PR04MB9081.eurprd04.prod.outlook.com ([fe80::2d29:445:cc37:a97f%5]) with mapi id 15.20.5061.022; Thu, 17 Mar 2022 08:59:25 +0000 Date: Thu, 17 Mar 2022 16:59:17 +0800 From: Michael Chang To: Paul Menzel , grub-devel@gnu.org Subject: Re: [PATCH 3/3] reed_solomon: Fix array subscript 0 is outside array bounds Message-ID: <20220317085917.GA25481@mazu> References: <20220317064342.25671-1-mchang@suse.com> <20220317064342.25671-4-mchang@suse.com> <7070992d-8e60-8f21-0f25-b30b57768cd8@molgen.mpg.de> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7070992d-8e60-8f21-0f25-b30b57768cd8@molgen.mpg.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: SG2PR06CA0113.apcprd06.prod.outlook.com (2603:1096:1:1d::15) To DU2PR04MB9081.eurprd04.prod.outlook.com (2603:10a6:10:2f0::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f8d8307-0e54-4b05-a4ad-08da07f46f47 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3858:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MoNWwH/JJ8ccEjscmWmZf96RcTsjnC0r3MMxIN7ExRhZlVG4kH+G4BiTncMEixWYUxbI6QQEjUOSabMh0E4CF/TErFNnaCOAjEgMVVopZwwGTmCjQThxEPZ6x6MEEwrwL/Ar6QP8vSrHO42F0Y8rPofUSJNC/WB0vlvZbqaE7WsYrWLsVUeBQ49Dac+w0ZLqW1vByhf/YmIE8A/3UJ5vQYxQz+YD4++alsRxTR+14XPcAM0qBOhQ92aXrEI7QiR+gUKQx5LH4VilAKXd7DKwAHZ9VKC2jYyx/5w2ZMWvRJbPEeKBzcAZfp2UOaZnCpY41x8k4SKyB8pDgHFHzUU1vdKzJG6Sg4OqQJMfIE9X+r3yA+E6CDkjJH5lQrvLN0p66sDFYGreIJsog52E6Br4oIzFwn+5LIdThPpAMtUdX+Y7ED2UFynQ8oxh1AA5U/c/NbCLp8V6THORTHGawyGKBbndzTJHQYg09u/M4a7YwWsw6wRuvfw2WUPzKBRRSdVlJ9cAcS8ecprucLFk8RpYHVoCVzFjABmO2VhRfl41MEC+FI1hepsM2oeb/UkiNp4wz8rGmRJ1gIY2cchtwycBHmuiPVaJ75gdBmu2BWQDgCMOAa0GDE0dZLnhNswymNUU2QddHx6pxtB9WxUabtCuEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB9081.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(7916004)(366004)(8936002)(1076003)(186003)(33656002)(6486002)(33716001)(508600001)(6666004)(86362001)(2906002)(316002)(83380400001)(30864003)(5660300002)(6506007)(8676002)(66476007)(66556008)(66946007)(38100700002)(9686003)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+dU2R3byIOOFr6Je4y2lx0oFJs1FCCY3uzjDU7C5cWduKo4JqQk8PdyHJI3j?= =?us-ascii?Q?ZskObfcxAU7VItss7FwNm+sZacnrYjKMhVzN9IYi4WUF5ru1A7VNO+5D4weW?= =?us-ascii?Q?sL8beGQ3x9JG1dUuIyKVT6cJ8rLl3I5/PEKsvZXgmyXOoMMVXA3AUZu9Yu7P?= =?us-ascii?Q?Nj+wt2CIAmIhNo1Etl0wS3DXA0TDmm+98JJc9l1Z3tuAT9OVfO6DYPhlaD2v?= =?us-ascii?Q?XLnNT8g7i+enSLnTVyKZTahI5pDCBtQFvvlpMCFcoVBS+jDpp0qwhNBglsZt?= =?us-ascii?Q?aj3qj/Y7UplSxE5sWogoMZvRp+pWbj69c8EEvzjPShmyRjKVei+74NttpoVM?= =?us-ascii?Q?TYFTuRAaqOK5ytCa2vs/LaUlUEwxOiggn2u3ejrQJaysh5YcyxOXqpLn7mw/?= =?us-ascii?Q?nB8Rj68dEDJc7rKB47iIzBWo2BmzMj909SPGVKraEzmSaDVokyLlROeV98Po?= =?us-ascii?Q?PxMRoM+hGNi/R9cQubRP2PpFVdY8CQGWTY7kkLuEZ8lUW9nRcyByPFG6PkAN?= =?us-ascii?Q?8EhGYHTotJpTWYkKl8XviR4Qx5yluqpeJXAmS6J3K0zhttjqbmRpcsUk+wG8?= =?us-ascii?Q?S7DSak1Xmq6z3ew1AllFXPduGHaSd6I/Keeo6dReK+lTWKx2AhZHPSbC4ynJ?= =?us-ascii?Q?rVkYetPLGD6grVqb5fZh99H64ecWlgFh/w/z5PMai5XnOGCOZKerDabGpolo?= =?us-ascii?Q?q936kTHN/X6lMB0uUfZeC+cP9ZIpUvAIm0Ap+fLdstLuRccuEOVhbp9jBcVI?= =?us-ascii?Q?wi47RHkkGyuF7BaMlZuKGTpDe9UQR+B/ndEYHYrnHHZqzgj6YdjOJFBTqPqr?= =?us-ascii?Q?iW7BgzSBNUkSwODzXmtVAK/PuiiEXEr1BTAbSjfmxg+5ASosT2YKfb1gZ8++?= =?us-ascii?Q?OCMpFVGhdv7o5YHfAEOMfvw6/Ik4QFNFji6Eo7Lrw55EwCaPN3Fd5uh4cUNB?= =?us-ascii?Q?XfGPzorGAojMR2AYlc0tPJt0RrcNRQijJiqZne9yufPZu9xqpxy1quDEeEXs?= =?us-ascii?Q?z9KcERxK31sgVtYClDLo1c8lpw+DYKgFRr//H/bg5NSU/+3AOKBl1kOMISUo?= =?us-ascii?Q?SDnpeKwyGEDLdSBIaIJ97lPG+TkCkqcKCnnY3OVseHxdGYQ6noFZVOxUWT63?= =?us-ascii?Q?DwPdXbafVu5eixZ2pMYv3fCjroT6zcAXpvzdt5OTVdABgwrjFs4+Jr5B3TAf?= =?us-ascii?Q?7gK8V8JwkMAABDxHWLkRJQpjtXHuYUWmjxtmW7J8iq0O5IJAi4pTCTeU+4pn?= =?us-ascii?Q?rMiKo1AgPAL09+AScNwr3cEJI5YV6N8ghDJ0VDblzerXoCO44iFE09YW9LuI?= =?us-ascii?Q?chY+yF59B9vr8LsYjPdWGHV63jQIr++wwKAMpHgxb5dwgceMchGc4XlilyWb?= =?us-ascii?Q?KDMdUsjmGCLOMdGbHMnRH7pq6uhi5s4HE+7r2uFS2/L733dKzLHhhqAhFLGz?= =?us-ascii?Q?A2KeP+7V/9olv/v8sXIefwdMrFV35XaB9053CE/WYJY38AEAC6v4Z4DVCbut?= =?us-ascii?Q?RupfHJi+OnyKgtBnr2k3j7EWrkmjbYO1gVSM?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f8d8307-0e54-4b05-a4ad-08da07f46f47 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB9081.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2022 08:59:24.9070 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: faLNkgE6uPFBZkf+7Scqn8nH5AXtoaBRwJdVFpHXPDk0k5SkC9Mo5P5Bb/hVNG8B X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3858 Received-SPF: pass client-ip=194.104.109.102; envelope-from=mchang@suse.com; helo=de-smtp-delivery-102.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2022 08:59:35 -0000 On Thu, Mar 17, 2022 at 08:41:32AM +0100, Paul Menzel wrote: > Dear Michael, > > > Thank you for working on that. > > > Am 17.03.22 um 07:43 schrieb Michael Chang via Grub-devel: > > The grub_absolute_pointer() is a compound expression that can only work > > within a function. We are out of luck here when the pointer variables > > require global definition due to ATTRIBUTE_TEXT that have to use fully > > initialized global definition because of the way linkers work. > > > > static gf_single_t * const gf_powx ATTRIBUTE_TEXT = (void *) 0x100000; > > > > For the reason given above, use gcc diagnostic pragmas to suppress the > > array-bounds warning. > > Can you please share the exact GCC warning messages? Yes. It is very long so I didn't put in the description: [ 184s] ../../grub-core/lib/reed_solomon.c: In function 'pol_evaluate': [ 184s] ../../grub-core/lib/reed_solomon.c:147:39: error: array subscript [1, 255] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 147 | s ^= gf_powx[(int) gf_powx_inv[pol[i]] + log_xn]; [ 184s] | ~~~~~~~~~~~^~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:147:21: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 147 | s ^= gf_powx[(int) gf_powx_inv[pol[i]] + log_xn]; [ 184s] | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] In function 'gf_mul', [ 184s] inlined from 'gf_mul' at ../../grub-core/lib/reed_solomon.c:106:1: [ 184s] ../../grub-core/lib/reed_solomon.c:110:35: error: array subscript [1, 255] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 110 | return gf_powx[(int) gf_powx_inv[a] + (int) gf_powx_inv[b]]; [ 184s] | ~~~~~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:110:58: error: array subscript [1, 255] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 110 | return gf_powx[(int) gf_powx_inv[a] + (int) gf_powx_inv[b]]; [ 184s] | ~~~~~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:110:17: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 110 | return gf_powx[(int) gf_powx_inv[a] + (int) gf_powx_inv[b]]; [ 184s] | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c: In function 'gauss_solve.constprop': [ 184s] ../../grub-core/lib/reed_solomon.c:231:21: error: array subscript 0 is outside array bounds of 'int[0]' [-Werror=array-bounds] [ 184s] 231 | if (chosenstat[i] == -1) [ 184s] | ~~~~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:235:14: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 235 | s ^= eq[i * (m + 1) + m]; [ 184s] | ~~^~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:234:24: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 234 | s ^= gf_mul (eq[i * (m + 1) + j], sol[j]); [ 184s] | ~~^~~~~~~~~~~~~~~~~ [ 184s] In function 'gauss_eliminate', [ 184s] inlined from 'gauss_solve.constprop' at ../../grub-core/lib/reed_solomon.c:227:3: [ 184s] ../../grub-core/lib/reed_solomon.c:201:39: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 201 | for (nzidx = 0; nzidx < m && (eq[i * (m + 1) + nzidx] == 0); [ 184s] | ~~^~~~~~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:205:17: error: array subscript 0 is outside array bounds of 'int[0]' [-Werror=array-bounds] [ 184s] 205 | chosen[i] = nzidx; [ 184s] | ~~~~~~~~~~^~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:206:24: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 206 | r = gf_invert (eq[i * (m + 1) + nzidx]); [ 184s] | ~~^~~~~~~~~~~~~~~~~~~~~ [ 184s] In function 'gf_invert', [ 184s] inlined from 'gauss_eliminate' at ../../grub-core/lib/reed_solomon.c:206:11, [ 184s] inlined from 'gauss_solve.constprop' at ../../grub-core/lib/reed_solomon.c:227:3: [ 184s] ../../grub-core/lib/reed_solomon.c:116:41: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 116 | return gf_powx[255 - (int) gf_powx_inv[a]]; [ 184s] | ~~~~~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:116:17: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 116 | return gf_powx[255 - (int) gf_powx_inv[a]]; [ 184s] | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] In function 'gauss_eliminate', [ 184s] inlined from 'gauss_solve.constprop' at ../../grub-core/lib/reed_solomon.c:227:3: [ 184s] ../../grub-core/lib/reed_solomon.c:211:23: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 211 | gf_single_t rr = eq[j * (m + 1) + nzidx]; [ 184s] | ^~ [ 184s] ../../grub-core/lib/reed_solomon.c:213:46: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 213 | eq[j * (m + 1) + k] ^= gf_mul (eq[i * (m + 1) + k], rr); [ 184s] | ~~^~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:213:15: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 213 | eq[j * (m + 1) + k] ^= gf_mul (eq[i * (m + 1) + k], rr); [ 184s] | ~~^~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:213:33: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 213 | eq[j * (m + 1) + k] ^= gf_mul (eq[i * (m + 1) + k], rr); [ 184s] | ^~ [ 184s] ../../grub-core/lib/reed_solomon.c:208:41: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 208 | eq[i * (m + 1) + j] = gf_mul (eq[i * (m + 1) + j], r); [ 184s] | ~~^~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:208:29: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 208 | eq[i * (m + 1) + j] = gf_mul (eq[i * (m + 1) + j], r); [ 184s] | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c: In function 'gauss_solve.constprop': [ 184s] ../../grub-core/lib/reed_solomon.c:224:19: error: array subscript 0 is outside array bounds of 'int[0]' [-Werror=array-bounds] [ 184s] 224 | chosenstat[i] = -1; [ 184s] | ~~~~~~~~~~~~~~^~~~ [ 184s] In function 'init_powx', [ 184s] inlined from 'grub_reed_solomon_recover' at ../../grub-core/lib/reed_solomon.c:412:3: [ 184s] ../../grub-core/lib/reed_solomon.c:125:18: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 125 | gf_powx_inv[0] = 0; [ 184s] | ~~~~~~~~~~~~~~~^~~ [ 184s] In function 'rs_recover', [ 184s] inlined from 'decode_block' at ../../grub-core/lib/reed_solomon.c:315:7, [ 184s] inlined from 'grub_reed_solomon_recover' at ../../grub-core/lib/reed_solomon.c:426:7: [ 184s] ../../grub-core/lib/reed_solomon.c:251:11: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 251 | if (sy[i] != 0) [ 184s] | ~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:279:24: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 279 | eqstat[errnum] = sy[0]; [ 184s] | ~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:279:20: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 279 | eqstat[errnum] = sy[0]; [ 184s] | ~~~~~~~~~~~~~~~^~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:292:16: error: array subscript 0 is outside array bounds of 'int[0]' [-Werror=array-bounds] [ 184s] 292 | mm[errpos[i]] ^= errvals[i]; [ 184s] | ~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:292:9: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 292 | mm[errpos[i]] ^= errvals[i]; [ 184s] | ~~^~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:292:31: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 292 | mm[errpos[i]] ^= errvals[i]; [ 184s] | ~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:292:21: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 292 | mm[errpos[i]] ^= errvals[i]; [ 184s] | ~~~~~~~~~~~~~~^~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:286:47: error: array subscript [1, 2147483646] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 286 | eqstat[(errnum + 1) * i + errnum] = sy[i]; [ 184s] | ~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:286:43: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 286 | eqstat[(errnum + 1) * i + errnum] = sy[i]; [ 184s] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:284:56: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 284 | eqstat[(errnum + 1) * (i - 1) [ 184s] | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ [ 184s] 285 | + j]); [ 184s] | ~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:283:56: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 283 | eqstat[(errnum + 1) * i + j] = gf_mul (errpot[j], [ 184s] | ~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:283:40: error: array subscript [2, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 283 | eqstat[(errnum + 1) * i + j] = gf_mul (errpot[j], [ 184s] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ [ 184s] 284 | eqstat[(errnum + 1) * (i - 1) [ 184s] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] 285 | + j]); [ 184s] | ~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:278:17: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 278 | eqstat[j] = 1; [ 184s] | ~~~~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:271:58: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 271 | if (pol_evaluate (sigma, rs2 - 1, 255 - i) == gf_powx[i]) [ 184s] | ~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:273:24: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 273 | errpot[errnum] = gf_powx[i]; [ 184s] | ~~~~~~~~~~~~~~~^~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:274:26: error: array subscript [0, 536870911] is outside array bounds of 'int[0]' [-Werror=array-bounds] [ 184s] 274 | errpos[errnum++] = s + rs - i - 1; [ 184s] | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:265:16: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 265 | sigma[i] = 0; [ 184s] | ~~~~~~~~~^~~ [ 184s] ../../grub-core/lib/reed_solomon.c:262:39: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 262 | eqstat[i * (rs2 + 1) + j] = sy[i+j]; [ 184s] | ~~^~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:262:35: error: array subscript [0, 2147483647] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 262 | eqstat[i * (rs2 + 1) + j] = sy[i+j]; [ 184s] | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ [ 184s] In function 'decode_block', [ 184s] inlined from 'grub_reed_solomon_recover' at ../../grub-core/lib/reed_solomon.c:426:7: [ 184s] ../../grub-core/lib/reed_solomon.c:318:41: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 318 | ptr[SECTOR_SIZE * j + i] = mstat[j]; [ 184s] | ~~~~~^~~ [ 184s] In function 'rs_recover', [ 184s] inlined from 'decode_block' at ../../grub-core/lib/reed_solomon.c:315:7, [ 184s] inlined from 'grub_reed_solomon_recover' at ../../grub-core/lib/reed_solomon.c:426:7: [ 184s] ../../grub-core/lib/reed_solomon.c:248:11: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 248 | sy[i] = pol_evaluate (mm, s + rs - 1, i); [ 184s] | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] In function 'decode_block', [ 184s] inlined from 'grub_reed_solomon_recover' at ../../grub-core/lib/reed_solomon.c:426:7: [ 184s] ../../grub-core/lib/reed_solomon.c:313:23: error: array subscript [1, 8388608] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 313 | mstat[j + ds] = rptr[SECTOR_SIZE * j + i]; [ 184s] | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:311:18: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 311 | mstat[j] = ptr[SECTOR_SIZE * j + i]; [ 184s] | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ [ 184s] In function 'init_powx', [ 184s] inlined from 'grub_reed_solomon_recover' at ../../grub-core/lib/reed_solomon.c:412:3: [ 184s] ../../grub-core/lib/reed_solomon.c:128:18: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 128 | gf_powx[i] = cur; [ 184s] | ~~~~~~~~~~~^~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:129:24: error: array subscript [255, 509] is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 129 | gf_powx[i + 255] = cur; [ 184s] | ~~~~~~~~~~~~~~~~~^~~~~ [ 184s] ../../grub-core/lib/reed_solomon.c:130:24: error: array subscript 0 is outside array bounds of 'gf_single_t[0]' {aka 'unsigned char[]'} [-Werror=array-bounds] [ 184s] 130 | gf_powx_inv[cur] = i; [ 184s] | ~~~~~~~~~~~~~~~~~^~~ Btw, here's completed list of global pointer with constant address for your reference. static gf_single_t * const gf_powx ATTRIBUTE_TEXT = (void *) 0x100000; static gf_single_t * const gf_powx_inv ATTRIBUTE_TEXT = (void *) 0x100200; static int *const chosenstat ATTRIBUTE_TEXT = (void *) 0x100300; static gf_single_t *const sigma ATTRIBUTE_TEXT = (void *) 0x100700; static gf_single_t *const errpot ATTRIBUTE_TEXT = (void *) 0x100800; static int *const errpos ATTRIBUTE_TEXT = (void *) 0x100900; static gf_single_t *const sy ATTRIBUTE_TEXT = (void *) 0x100d00; static gf_single_t *const mstat ATTRIBUTE_TEXT = (void *) 0x100e00; static gf_single_t *const errvals ATTRIBUTE_TEXT = (void *) 0x100f00; static gf_single_t *const eqstat ATTRIBUTE_TEXT = (void *) 0x101000; Thanks, Michael > > > Kind regards, > > Paul > > > > Signed-off-by: Michael Chang > > --- > > grub-core/lib/reed_solomon.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c > > index 82779a296b..562bd2e3e3 100644 > > --- a/grub-core/lib/reed_solomon.c > > +++ b/grub-core/lib/reed_solomon.c > > @@ -102,6 +102,11 @@ static gf_single_t errvals[256]; > > static gf_single_t eqstat[65536 + 256]; > > #endif > > +#if __GNUC__ == 12 > > +#pragma GCC diagnostic push > > +#pragma GCC diagnostic ignored "-Warray-bounds" > > +#endif > > + > > static gf_single_t > > gf_mul (gf_single_t a, gf_single_t b) > > { > > @@ -319,6 +324,10 @@ decode_block (gf_single_t *ptr, grub_size_t s, > > } > > } > > +#if __GNUC__ == 12 > > +#pragma GCC diagnostic pop > > +#endif > > + > > #if !defined (STANDALONE) > > static void > > encode_block (gf_single_t *ptr, grub_size_t s,