Issue2598

Title 2598. addressof works on temporaries
Status open Section [specialized.addressof]
Submitter Brent Friedman

Created on 2016-03-06.00:00:00 by admin, last changed by admin.

Messages
msg8346 (view) Date: 2016-08-03.12:32:27

Proposed resolution:

This wording is relative to N4582.

  1. Change [memory.syn], header <memory> synopsis, as indicated:

    […]
    // 20.9.12, specialized algorithms:
    template <class T> constexpr T* addressof(T& r) noexcept;
    template <class T> const T* addressof(const T&& elem) = delete;
    […]
    
  2. Change [specialized.addressof] p1 as indicated:

    template <class T> constexpr T* addressof(T& r) noexcept;
    template <class T> const T* addressof(const T&& elem) = delete;
    

    -1- Returns: The actual address of the object or function referenced by r, even in the presence of an overloaded operator&.

msg8019 (view) Date: 2016-08-06.21:31:18

[ 2016-08 Chicago ]

Tues PM: Move to Tentatively Ready

msg8018 (view) Date: 2016-03-06.00:00:00

LWG issue 970 removed the rvalue reference overload for addressof. This allows const prvalues to bind to a call to addressof, which is dissimilar from the behavior of operator&.

const vector<int> a();

void b()
{
  auto x = addressof(a()); // "ok"
  auto y = addressof<const int>(0); // "ok"
  auto z = &a(); //error: cannot take address of a temporary
}
History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> open
2016-11-14 03:59:28adminsetstatus: open -> wp
2016-11-14 03:55:22adminsetstatus: ready -> open
2016-08-03 12:32:27adminsetstatus: new -> ready
2016-08-03 12:32:27adminsetmessages: + msg8346
2016-04-07 21:11:48adminsetmessages: + msg8019
2016-03-06 00:00:00admincreate