[llvm-bugs] [Bug 48585] New: Clang incorrectly discards constructor of global variable
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Dec 23 12:18:33 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48585
Bug ID: 48585
Summary: Clang incorrectly discards constructor of global
variable
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: mschellenbergercosta at googlemail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
This is an issue that came up with the implementation of constexpr vector and
constexpr string for MSVCs standard library.
The regression is that the constructor of vector (or string) is not executed
properly, which lets the iterator debug machinery of the STL crash.
A minimal reproducer of he issue is the following code
```
struct container_proxy {};
struct container_base {
constexpr void alloc_proxy() {
if (!__builtin_is_constant_evaluated()) {
proxy = &storage;
}
}
container_proxy storage; // Must be a struct, compiles fine with int
container_proxy* proxy = nullptr;
};
struct container {
constexpr container() {
data.alloc_proxy(); //The call to this function is ommited
}
container_base data;
};
container globalVariable;
int main() {
if (globalVariable.data.proxy == nullptr) {
return -1;
}
}
```
I would expect, that global variables that are not constant expressions are
still constructed correctly.
As a side note, the code executes fine if the container_proxy struct is
replaced by a POD type such as int.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201223/e3c0432e/attachment.html>
More information about the llvm-bugs
mailing list