public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "goswin-v-b at web dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr Date: Sat, 12 Feb 2022 14:47:12 +0000 [thread overview] Message-ID: <bug-104514-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104514 Bug ID: 104514 Summary: add feature to create a pointer to a fixed address as constexpr Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: goswin-v-b at web dot de Target Milestone: --- In the embedded and micro controller world memory mapped registers are very common. They can be declared as external object and fudged in using linker scripts, which prevents a lot of optimizations. Or they can be declared as pointers, in the most reduced form like this: int *p = (int*)0x12345678; My problem now is that this isn't a constexpr and can't be used in any constexpr code: foo.cc:1:20: error: ‘reinterpret_cast’ from integer to pointer 1 | constexpr int *p = (int*)0x12345678; | ^~~~~~~~~~~~~~~~ While this is the right thing in general there should be a way to allow this special case. A way to tell the compiler that an object exists at a fixed address and still be a constexpr.
next reply other threads:[~2022-02-12 14:47 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-12 14:47 goswin-v-b at web dot de [this message] 2022-02-12 21:55 ` [Bug c++/104514] " pinskia at gcc dot gnu.org 2022-02-13 12:06 ` redi at gcc dot gnu.org 2022-02-13 22:44 ` pinskia at gcc dot gnu.org 2022-02-14 3:03 ` pinskia at gcc dot gnu.org 2022-02-14 11:57 ` redi at gcc dot gnu.org 2022-02-15 8:27 ` q.gcc@rsn-tech.co.uk
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-104514-4@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).