From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1A052383F875; Wed, 15 Jul 2020 21:09:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A052383F875 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594847381; bh=cVWgVw4GdISdNFtKDlIo7EHLthXtPzeyGfJefFyHtSU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZXoI8/QCAeqZr+gXIB+dy4tkU4B4uABH8MWQ2tBL7LOQwsj8buyLbDTZu4qIC9whR 7Bv2vaBBwTflqi726+fOQ/GsDlPELidZsLFAynvxFf4JUg/TAILiII0xMPO4+kl64b IoOTeNxrVaRpmpJPdE6HCwEIy3qMbgQhO1aMPTYY= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95942] [11 regression] offsetof on an array: error: 'e' is not a constant expression Date: Wed, 15 Jul 2020 21:09:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jul 2020 21:09:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95942 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- struct S { int a; int b[15]; }; int foo (int n) { int m =3D n; return __builtin_offsetof (S, b[m]); } has been rejected for years, while struct S { int a; int b[15]; }; int foo (int n) { return __builtin_offsetof (S, b[n]); } has been accepted. The comment in cp/parser.c says: /* ??? For offsetof, there is a question of what to allow here. If offsetof is not being used in an integral constant expression context, then we *could* get the right answer by computing the value at runtime. If we are in an integral constant expression context, then we might could accept any constant expression; hard to say without analysis. Rather than open the barn door too wide right away, allow only integer constant expressions here. */=