[PATCH] D74361: [Clang] Undef attribute for global variables

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 18:54:02 PST 2020


Quuxplusone added inline comments.


================
Comment at: clang/test/CodeGenCXX/attr-no-zero-initializer.cpp:40
+// CHECK: @unt = global %struct.nontrivial undef
+nontrivial unt [[clang::no_zero_initializer]];
----------------
Can you explain a bit about how this interacts with C++ constructors? Will this object not have its constructor called at startup; or is it that the constructor will be called but the memory simply won't have been zeroed //before// calling the constructor?

For [P1144 relocation](https://wg21.link/p1144) (D50114, D61761, etc), Anton Zhilin and I have been discussing the possibility of a similar-sounding attribute that would skip the constructor of a local variable altogether, allowing someone to write e.g.
```
T relocate(T *source) {
    [[unconstructed]] T result;
    memcpy(result, source, sizeof(T));
    return result;
}
```
If your attribute does exactly that, then I'm interested. If your attribute doesn't do that, but is occupying real estate that //implies// that it does, then I'm also interested.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74361/new/

https://reviews.llvm.org/D74361





More information about the cfe-commits mailing list