cplusplus / nbballot

Handling of NB comments in response to ballots
14 stars 4 forks source link

GB-121 27.11.1 [specialized.algorithms.general] Remove voidify #452

Closed wg21bot closed 1 year ago

wg21bot commented 1 year ago

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.

CaseyCarter commented 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.

brycelelbach commented 1 year ago

2022-11-08 15:15 to 17:00 UTC-10 Kona Library Evolution Meeting

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

Next Steps

Take a Library Evolution electronic poll to send the proposed resolution to GB-121 (Remove voidify) to Library for C++23.

jwakely commented 1 year ago

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.

Core 2514 might change that, removing those benefits in most cases where they might otherwise have applied.

brycelelbach commented 1 year ago

2022-11 Library Evolution Electronic Poll Outcomes

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.

brycelelbach commented 1 year ago

@JeffGarland heads up.

jwakely commented 1 year ago

This is now LWG 3870.

JeffGarland commented 1 year ago

Reviewed and approved at Issaquah -- see issue for details.

jwakely commented 1 year ago

Accepted with modification.