Skip to content

[2026-06 LWG Motion 17] P3125R6 constexpr pointer tagging#9120

Merged
tkoeppe merged 1 commit into
cplusplus:mainfrom
eisenwave:motions-2026-06-lwg-17
Jul 16, 2026
Merged

[2026-06 LWG Motion 17] P3125R6 constexpr pointer tagging#9120
tkoeppe merged 1 commit into
cplusplus:mainfrom
eisenwave:motions-2026-06-lwg-17

Conversation

@eisenwave

Copy link
Copy Markdown
Member

Fixes #9104
Also fixes cplusplus/papers#1903

@eisenwave eisenwave added this to the post-2026-06 milestone Jun 14, 2026
@eisenwave eisenwave requested a review from jwakely June 14, 2026 13:31
@eisenwave

Copy link
Copy Markdown
Member Author

Need some help resolving the FIXMEs.

Comment thread source/memory.tex Outdated
Comment thread source/memory.tex
\pnum
\tcode{tagged_pointer_type} denotes \cv{}~\tcode{void*},
%FIXME: what do we mean by "pointer denotes"? \tcode{pointer()}?
for \cv{} such that pointer denotes \cv{}~\tcode{U*} for some type \tcode{U}.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC the "pointer" should be pointer_type.

I wonder whether \result is suitable here. Also, IIUC, we can just use using tagged_pointer_type = common_type_t<void*, pointer_type>;.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwakely how do we fix this? Editorially or LWG issue, and in this PR or elsewhere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the intended meaning is clear. R4 and R5 had:

    using tagged_pointer_type = conditional_t<is_const_v<pointer>, const void *, void *>;

But pointer isn't even defined, and presumably what it was meant to mean was is_const_v<remove_pointer_t<Ptr>>.

I think this needs an LWG issue unless @hanickadot can clarify.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supposed to be COPYCV equivalent of this https://eel.is/c++draft/meta.trans.other#3.3

so tagged_pointer_type has same CV-qualifiers as pointer_type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointer_tag_pair<const T *, N>::tagged_pointer_type should be const void *

pointer_tag_pair<volatile T *, N>::tagged_pointer_type should be volatile void *

pointer_tag_pair<T *, N>::tagged_pointer_type should be void *

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know I can use std::common_type_t as @frederick-vs-ja proposed.

Originally it was supposed to be an unspecified type, maybe uintptr_t, (CV) void * ... as I went thru many back and forth with Jens in lib-ext@ mailing list to find something which works, he was concerned LEWG wasn't fully aware about the effects of the functionality returning basically always an invalid pointer value. Which until recently had implementation defined behavior for lvalue-to-rvalue conversion (not anymore).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's follow it up later then. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wrote replies, there, but didn't notice I need to submit them in "Files Changes" tab 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave it to you and LWG to decide if this is editorial - if so, please send a PR and I can include it in the new draft!

@tkoeppe tkoeppe force-pushed the motions-2026-06-lwg-17 branch 4 times, most recently from cd64b11 to 0f665e9 Compare July 15, 2026 23:59
Editorial notes:
  * Used standard synposis comments with xrefs to subclauses.
  * [ptrtag.pair.general] In the synopsis, move "tagged_pointer" up
    to the "tagged pointer operations", corresponding to the subclause
    in which the specification appears.
  * Minor punctuation fixes.
@tkoeppe tkoeppe force-pushed the motions-2026-06-lwg-17 branch from 0f665e9 to 907710e Compare July 16, 2026 00:08
@tkoeppe tkoeppe merged commit 254deba into cplusplus:main Jul 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2026-06 LWG Motion 17] P3125R6 (constexpr pointer tagging) P3125 R5 constexpr pointer tagging

5 participants