public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-95942-4-fmWaAmAA3s@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-95942-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95942 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- struct S { int a; int b[15]; }; int foo (int n) { int m = 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. */
next prev parent reply other threads:[~2020-07-15 21:09 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-27 18:22 [Bug c++/95942] New: " slyfox at inbox dot ru 2020-06-27 18:29 ` [Bug c++/95942] " slyfox at inbox dot ru 2020-06-27 18:34 ` mpolacek at gcc dot gnu.org 2020-06-29 10:37 ` rguenth at gcc dot gnu.org 2020-07-15 20:26 ` ppalka at gcc dot gnu.org 2020-07-15 20:56 ` slyfox at inbox dot ru 2020-07-15 21:09 ` jakub at gcc dot gnu.org [this message] 2020-10-12 12:51 ` rguenth at gcc dot gnu.org 2020-10-15 16:45 ` jason at gcc dot gnu.org 2020-10-15 21:40 ` slyfox at gcc dot gnu.org 2021-04-27 19:39 ` jakub at gcc dot gnu.org 2024-02-07 15:06 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-95942-4-fmWaAmAA3s@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).