CWG Issue 2018 (original) (raw)
This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-05
2018. Qualification conversion vs reference binding
Section: 9.5.4 [dcl.init.ref]Status: dupSubmitter: Richard SmithDate: 2014-10-07
Qualification conversions are not considered when doing reference binding, which leads to some unexpected results:
template T make(); struct B {}; struct D : B {};
const int *p1 = make<int*>(); // ok, qualification conversion const int *const *p2 = make<int**>(); // ok, qualification conversion const int **p3 = make<int**>(); // error, not type safe
const int &r1 = make<int&>(); // ok, binds directly const int *const &r2 = make<int*&>(); // weird, binds to a temporary const int *&r3 = make<int*&>(); // error
const int &&x1 = make<int&&>(); // ok, binds directly const int *const &&x2 = make<int*&&>(); // weird, binds to a temporary const int *&&x3 = make<int*&&>(); // weird, binds to a temporary
It might make sense to say that similar types are reference-related and if there is a qualification conversion they are reference-compatible.
See also issue 2023.
Rationale (September, 2023):
This issue is a duplicate of issue 2352.