Title
Regression on result of conditional operator
Status
dr
Section
7.6.16 [expr.cond]
Submitter
Christof Meerwald

Created on 2024-01-14.00:00:00 last changed 4 months ago

Messages

Date: 2024-05-04.22:02:54

Proposed resolution (approved by CWG 2024-05-03):

Change in 7.6.16 [expr.cond] bullet 4.3 as follows:

  • ...
  • If E2 is a prvalue or if neither of the conversion sequences above can be formed and at least one of the operands has (possibly cv-qualified) class type:
    • if T1 and T2 are the same class type (ignoring cv-qualification):
      • and if T2 is at least as cv-qualified as T1, the target type is T2,
      • otherwise, no conversion sequence is formed for this operand;
    • otherwise, if T2 is a base class of T1, the target type is cv1 T2, where cv1 denotes the cv-qualifiers of T1, ;
    • otherwise, the target type is the type that E2 would have after applying the lvalue-to-rvalue (7.3.2 [conv.lval]), array-to-pointer (7.3.3 [conv.array]), and function-to-pointer (7.3.4 [conv.func]) standard conversions.
Date: 2024-06-15.00:00:00

[Accepted as a DR at the June, 2024 meeting.]

Consider:

  #include <concepts>

  template <class T> T get();

  template <class T>
  using X = decltype(true ? get<T const&>() : get<T>());

  struct C { };

  static_assert(std::same_as<X<int>, int>);
  static_assert(std::same_as<X<C>, C const>);  // #1

Before Issue 1895, #1 was well-formed. With the reformulation based on conversion sequences, #1 is now ill-formed because both conversion sequences can be formed.

History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: ready -> dr
2024-06-27 04:25:11adminsetstatus: tentatively ready -> ready
2024-05-04 22:02:54adminsetmessages: + msg7688
2024-05-04 22:02:54adminsetstatus: open -> tentatively ready
2024-01-14 00:00:00admincreate