Consider this code:
struct TNumeric {
bool Negative;
wstring Integral;
wstring Fraction;
};
union TValue {
// The unnamed structs are needed because otherwise the compiler does not accept it...
bool Bit;
struct{ TNumeric Numeric; };
struct{ wstring Text; };
};
TNumeric Numeric;
TNumeric &rNumeric{ Numeric };
rNumeric.Integral = L"";
rNumeric.Integral.push_back( L'X' ); //OK, no problem
TValue Value;
TValue &rValue{ Value };
rValue.Text = L"";
rValue.Text.push_back( L'X' ); //OK, no problem
rValue.Numeric.Integral = L"";
rValue.Numeric.Integral.push_back( L'X' ); // Exception
In release mode there is no problem. When run in debug mode there is an exception at the last statement in method _Adopt of class _Iterator_base12 in xutility: Access violation reading location 0x0000005C
.
In _Adopt the code is only run when _ITERATOR_DEBUG_LEVEL == 2
. I tried with
#define _ITERATOR_DEBUG_LEVEL 1
added in my main program but it remains defined as 2. Is there a way to disable the check?
Aucun commentaire:
Enregistrer un commentaire