[PATCH] D40144: Implement `std::launder`

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 19:22:37 PST 2017


EricWF added inline comments.


================
Comment at: include/new:274
+{
+    return __launder(__p);
+}
----------------
The call should probably be qualified to `_VSTD::__launder`.


================
Comment at: test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp:16
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+
----------------
Why is this test unsupported with older compilers? The version of `std::launder` in this patch should work regardless of compiler support for `__builtin_launder`.

Although, it's possible the compiler requirements were intended to avoid older clang versions without `[[nodiscard]]`. However, I don't think `clang-3.8` supports C++2a, so the condition seems redundant.



================
Comment at: test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp:28
+    void *p = nullptr;
+    (void) std::launder((               void *) nullptr);  // expected-error-re at new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+    (void) std::launder((const          void *) nullptr);  // expected-error-re at new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
----------------
Alternatively you could de-duplicate the four identical checks into the single check:

```
// expected-error-re at new:* 4 {{static_assert failed{{.*}} "can't launder cv-void"}}
```


https://reviews.llvm.org/D40144





More information about the cfe-commits mailing list