Closed wg21bot closed 1 year ago
The only claimed benefit is allowing the uninitialized_xxx algorithms to create objects in const storage (including overwriting objects declared as const which is usually UB). The caller should be responsible for using const_cast if that's really desirable.
The claimed benefit is allowing the uninitialized_xxx algorithms to create objects of const
and/or volatile
type, which they cannot otherwise do since they deduce the type of object to be created from the reference type of the pertinent iterator. Creating const
objects has some (marginal?) benefits over using const
pointers to mutable objects. For example, their non-mutable members cannot be modified via casting away const
without undefined behavior. A unit test might take advantage of this behavior to force a compiler to diagnose such undefined behavior in a constant expression.
LEWG is welcome to relitigate this decision every Standard cycle if they like, but perhaps someone should record the facts in a paper so we don't need to re-establish them every three years.
GB-121: Remove voidify
2022-11-08 15:15 to 17:00 UTC-10 Kona Library Evolution Minutes
Champion: Jonathan Wakely (remote)
Chair: Bryce Adelstein Lelbach & Billy Baker
Minute Taker: Mark Zeren
Start: 2022-11-08 15:44 UTC-10
POLL: Send the proposed resolution to GB-121 (Remove voidify
) to Library for C++23, to be confirmed by a Library Evolution electronic poll.
Strongly Favor | Weakly Favor | Neutral | Weakly Against | Strongly Against |
---|---|---|---|---|
3 | 14 | 3 | 0 | 0 |
Attendance: 19 (in-person) + 5 (remote)
# of Authors: 1
Author Position: SF
Outcome: Strong consensus in favor.
End: 15:59
Take a Library Evolution electronic poll to send the proposed resolution to GB-121 (Remove voidify
) to Library for C++23.
Creating
const
objects has some (marginal?) benefits over usingconst
pointers to mutable objects. For example, their non-mutable members cannot be modified via casting awayconst
without undefined behavior.
Core 2514 might change that, removing those benefits in most cases where they might otherwise have applied.
Poll 1.22: Send the proposed resolution to C++23 National Body comment GB-121 Remove voidify to Library Working Group for C++23, classified as an improvement of an existing feature ([P0592R4] bucket 2 item).
Strongly Favor | Weakly Favor | Neutral | Weakly Against | Strongly Against |
---|---|---|---|---|
9 | 9 | 1 | 1 | 0 |
Outcome: Consensus in favor.
@JeffGarland heads up.
Reviewed and approved at Issaquah -- see issue for details.
Accepted with modification.
The "voidify" helper breaks const-correctness, for no tangible benefit. C++20 ballot comment US 215 also suggested removing it, but failed to achieve consensus. That should be reconsidered.
The only claimed benefit is allowing the uninitialized_xxx algorithms to create objects in const storage (including overwriting objects declared as const which is usually UB). The caller should be responsible for using const_cast if that's really desirable. Implicitly removing 'const' is unsafe and unnecessary.
Remove "voidify" throughout Clause 27. Use
static_cast<void*>(addressof(x))
instead.