Skip to content

[out.ptr.t][inout.ptr.t] The notes for operator void** might suggest violation of the strict aliasing rule #4701

@frederick-vs-ja

Description

@frederick-vs-ja

The suggested implementation strategy can make the stored Pointer member subobject modified via a void* lvalue, which violates the strict aliasing rule ([basic.lval]/11), and might result in miscompilation on compilers that make use of TBAA.
A std::byte array member of appropriate size and alignment is suitable for the required type punning due to implicit object creation (the destructor can read p by std::bit_cast if the such strategy is used).

As the strategy using a byte array may be too delicate for a note, can we just remove the notes, or replace the wording with a less detailed one?
(E.g. Recommended practice: If possible, implementations should use no additional storage with respect to that for p in order to support both conversion functions.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions