public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Bug with GCC's handling of lifetimes of implicit-lifetime types
@ 2022-12-10 17:41 Gavin Ray
  2022-12-10 18:35 ` Jonathan Wakely
  0 siblings, 1 reply; 10+ messages in thread
From: Gavin Ray @ 2022-12-10 17:41 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

This came up when I was asking around about what the proper way was to:

- Allocate aligned storage for a buffer pool/page cache
- Then create pointers to "Page" structs inside of the storage memory area

I thought something like this might do:

struct buffer_pool
{
  alignas(PAGE_SIZE) std::byte storage[NUM_PAGES * PAGE_SIZE];
  page* pages = new (storage) page[NUM_PAGES];
}

Someone told me that this was a valid solution but not to do it, because it
wouldn't function properly on GCC
They gave this as a reproduction:

https://godbolt.org/z/EhzM37Gzh

I'm not experienced enough with C++ to grok the connection between this
repro and my code, but I figured
I'd post it on the mailing list in case it was useful for others/might get
fixed in the future =)

They said it had to do with "handling of lifetimes of implicit-lifetime
types"

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

end of thread, other threads:[~2022-12-12 11:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-10 17:41 Bug with GCC's handling of lifetimes of implicit-lifetime types Gavin Ray
2022-12-10 18:35 ` Jonathan Wakely
2022-12-10 18:43   ` Andrew Pinski
2022-12-10 21:48     ` Gavin Ray
2022-12-11  9:11     ` Richard Biener
2022-12-11 12:02       ` Jonathan Wakely
2022-12-11 13:31         ` Richard Biener
2022-12-11 13:38           ` Gavin Ray
2022-12-11 13:44             ` Gavin Ray
2022-12-12 11:56               ` Jonathan Wakely

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