Issue 204082
Summary [libcxx] `std::get_temporary_buffer` breaks standard
Labels libc++
Assignees
Reporter futog
    ```
#include <cassert>
#include <memory>
#include <utility>

struct A {
  int x;
};

int main() {
  std::pair<A *, std::ptrdiff_t> buff = std::get_temporary_buffer<A>(-1);
  assert(buff.first == nullptr); // OK
 assert(buff.second == 0); // NOK, == -1
}
```
>From the standard ISO/IEC 14882:2017:
```
D.11 Temporary buffers

template <class T>
pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;

Returns: If n <= 0 or if no storage could be obtained, returns a pair P such that P.first is a null pointer value and P.second == 0; otherwise returns a pair P such that P.first refers to the address of the uninitialized storage and P.second refers to its capacity N (in the units of sizeof(T)).
```
Note: Note: deprecated in C++17, removed from C++20
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to