Avoid a zero-length array for the FlexArray definition

Newer GCCs are warning about FlexArray being used at the end of another struct.
Though not the most ideal to always allocate space for at least 1 element,
actual 0-sized uses are rare and for smaller element types.
This commit is contained in:
Chris Robinson
2020-08-15 23:22:10 -07:00
parent 2fa842a04c
commit 23259b48dd
2 changed files with 5 additions and 10 deletions
+1 -5
View File
@@ -947,13 +947,9 @@ constexpr int alcEFXMinorVersion{0};
/* To avoid extraneous allocations, a 0-sized FlexArray<ALCcontext*> is defined
* globally as a sharable object. MSVC warns that a zero-sized array will have
* zero objects here, so silence that.
* globally as a sharable object.
*/
DIAGNOSTIC_PUSH
msc_pragma(warning(disable : 4815))
al::FlexArray<ALCcontext*> EmptyContextArray{0u};
DIAGNOSTIC_POP
using DeviceRef = al::intrusive_ptr<ALCdevice>;
+4 -5
View File
@@ -179,11 +179,10 @@ struct FlexArray {
const index_type mSize;
DIAGNOSTIC_PUSH
std_pragma("GCC diagnostic ignored \"-Wpedantic\"")
msc_pragma(warning(disable : 4200))
alignas(alignment) element_type mArray[0];
DIAGNOSTIC_POP
union {
char mDummy;
alignas(alignment) element_type mArray[1];
};
static std::unique_ptr<FlexArray> Create(index_type count)
{