public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr
@ 2022-02-12 14:47 goswin-v-b at web dot de
  2022-02-12 21:55 ` [Bug c++/104514] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: goswin-v-b at web dot de @ 2022-02-12 14:47 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/104514] add feature to create a pointer to a fixed address as constexpr
  2022-02-12 14:47 [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr goswin-v-b at web dot de
@ 2022-02-12 21:55 ` pinskia at gcc dot gnu.org
  2022-02-13 12:06 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-12 21:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104514

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/104514] add feature to create a pointer to a fixed address as constexpr
  2022-02-12 14:47 [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr goswin-v-b at web dot de
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-13 12:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104514

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is forbidden by C++, but I've started writing a proposal for a language
feature to support this use case

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/104514] add feature to create a pointer to a fixed address as constexpr
  2022-02-12 14:47 [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr goswin-v-b at web dot de
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-13 22:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104514

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-02-13
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I thought there was another bug open asking for this same thing but I can't
find it right now.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/104514] add feature to create a pointer to a fixed address as constexpr
  2022-02-12 14:47 [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr goswin-v-b at web dot de
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-14  3:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104514

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=80886

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> I thought there was another bug open asking for this same thing but I can't
> find it right now.

Oh yes PR 80886.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/104514] add feature to create a pointer to a fixed address as constexpr
  2022-02-12 14:47 [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr goswin-v-b at web dot de
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-14 11:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104514

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, but this one asks for a new feature, not just "please make this kluge work
again".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/104514] add feature to create a pointer to a fixed address as constexpr
  2022-02-12 14:47 [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr goswin-v-b at web dot de
                   ` (4 preceding siblings ...)
  2022-02-14 11:57 ` redi at gcc dot gnu.org
@ 2022-02-15  8:27 ` q.gcc@rsn-tech.co.uk
  5 siblings, 0 replies; 7+ messages in thread
From: q.gcc@rsn-tech.co.uk @ 2022-02-15  8:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104514

--- Comment #5 from steveren <q.gcc@rsn-tech.co.uk> ---
In fairness, I was asking for a lost capability to be restored, and I think it
was implicit that a proper mechanism would be better than the pre-existing
kluge :-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-02-15  8:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-12 14:47 [Bug c++/104514] New: add feature to create a pointer to a fixed address as constexpr goswin-v-b at web dot de
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

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).