Avoid exit-time destructors.
operator[]() was recently changed to use the existing code in order to correctly align the returned pointer; however this broke -Wexit-time-destructors. Change to a method that is still correctly aligned but does not generate a destructor.
This commit is contained in:
parent
0390b1ad57
commit
4695953567
@ -1230,6 +1230,7 @@ public:
|
|||||||
else {
|
else {
|
||||||
RAPIDJSON_ASSERT(false); // see above note
|
RAPIDJSON_ASSERT(false); // see above note
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && (__cplusplus >= 201103L)
|
||||||
// This will generate -Wexit-time-destructors in clang
|
// This will generate -Wexit-time-destructors in clang
|
||||||
// static GenericValue NullValue;
|
// static GenericValue NullValue;
|
||||||
// return NullValue;
|
// return NullValue;
|
||||||
@ -1237,6 +1238,10 @@ public:
|
|||||||
// Use static buffer and placement-new to prevent destruction
|
// Use static buffer and placement-new to prevent destruction
|
||||||
alignas(GenericValue) static char buffer[sizeof(GenericValue)];
|
alignas(GenericValue) static char buffer[sizeof(GenericValue)];
|
||||||
return *new (buffer) GenericValue();
|
return *new (buffer) GenericValue();
|
||||||
|
#else
|
||||||
|
static GenericValue buffer;
|
||||||
|
return *new (reinterpret_cast<char *>(&buffer)) GenericValue();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <typename SourceAllocator>
|
template <typename SourceAllocator>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user