@@ -102,6 +102,8 @@ bool Align(unsigned &pos, unsigned end, unsigned align) {
102
102
}
103
103
104
104
struct Element {
105
+ Element () = default ;
106
+ Element (const Element&) = default ;
105
107
Element (unsigned id, unsigned start, unsigned end) : id(id), start(start), end(end) {}
106
108
bool operator <(const Element &other) { return id < other.id ; }
107
109
unsigned id; // index in original ordered vector
@@ -663,7 +665,7 @@ TEST_F(AllocatorTest, GapFilling) {
663
665
664
666
TEST_F (AllocatorTest, Allocate) {
665
667
WEX::TestExecution::SetVerifyOutput verifySettings (WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
666
- for (auto && scenario : m_Scenarios) {
668
+ for (auto &scenario : m_Scenarios) {
667
669
668
670
// Test for alignment 1 (no alignment), then alignment 4
669
671
unsigned alignment = 1 ;
@@ -678,11 +680,14 @@ TEST_F(AllocatorTest, Allocate) {
678
680
Allocator alloc (scenario.Min , scenario.Max );
679
681
VERIFY_IS_TRUE (scenario.InsertSpans (alloc));
680
682
683
+ // This needs to be allocated outside the control flow because we need the
684
+ // stack allocation to remain valid until the spans are verified.
685
+ Element e;
681
686
if (!largestGap || // no gaps
682
687
(sizeLess1 < UINT_MAX && sizeLess1 > largestGap->sizeLess1 ) || // not unbounded and size too large
683
688
(sizeLess1 == UINT_MAX && !pEndGap)) { // unbounded and no end gap
684
689
// no large enough gap, should fail to allocate
685
- Element e (UINT_MAX, 0 , 0 );
690
+ e = Element (UINT_MAX, 0 , 0 );
686
691
unsigned pos = 0xFEFEFEFE ;
687
692
if (sizeLess1 == UINT_MAX) {
688
693
VERIFY_IS_FALSE (alloc.AllocateUnbounded (&e, pos, alignment));
@@ -699,7 +704,7 @@ TEST_F(AllocatorTest, Allocate) {
699
704
DXASSERT_NOMSG (expectedGap);
700
705
unsigned start = expectedGap->start ;
701
706
unsigned end = expectedGap->start + sizeLess1;
702
- Element e (UINT_MAX, start, end);
707
+ e = Element (UINT_MAX, start, end);
703
708
unsigned pos = 0xFEFEFEFE ;
704
709
if (sizeLess1 == UINT_MAX) {
705
710
e.end = expectedGap->end ;
0 commit comments