@@ -8492,19 +8492,19 @@ static size_t bitCeil(size_t x)
84928492 return x + 1 ;
84938493}
84948494
8495- static size_t getAlignOf (const ValueType& vt, const Settings& settings, ValueType::Accuracy accuracy, int maxRecursion = 0 )
8495+ static size_t getAlignOf (const ValueType& vt, const Settings& settings, ValueType::Accuracy accuracy, ValueType::SizeOf sizeOf, int maxRecursion = 0 )
84968496{
84978497 if (maxRecursion == settings.vfOptions .maxAlignOfRecursion ) {
84988498 // TODO: add bailout message
84998499 return 0 ;
85008500 }
8501- if (vt.pointer || vt.reference != Reference::None || vt.isPrimitive ()) {
8501+ if (( vt.pointer && sizeOf == ValueType::SizeOf::Pointer) || vt.reference != Reference::None || vt.isPrimitive ()) {
85028502 auto align = vt.getSizeOf (settings, accuracy, ValueType::SizeOf::Pointer);
85038503 return align == 0 ? 0 : bitCeil (align);
85048504 }
85058505 if (vt.type == ValueType::Type::RECORD && vt.typeScope ) {
85068506 auto accHelper = [&](size_t max, const ValueType& vt2, size_t /* dim*/ , MathLib::bigint /* bits*/ ) {
8507- size_t a = getAlignOf (vt2, settings, accuracy, ++maxRecursion);
8507+ size_t a = getAlignOf (vt2, settings, accuracy, sizeOf, ++maxRecursion);
85088508 return std::max (max, a);
85098509 };
85108510 Result result = accumulateStructMembers (vt.typeScope , accHelper, accuracy);
@@ -8558,7 +8558,7 @@ size_t ValueType::getSizeOf( const Settings& settings, Accuracy accuracy, SizeOf
85588558 auto accHelper = [&](size_t total, const ValueType& vt2, size_t dim, MathLib::bigint nBits) -> size_t {
85598559 const size_t charBit = settings.platform .char_bit ;
85608560 size_t n = vt2.getSizeOf (settings, accuracy, SizeOf::Pointer, ++maxRecursion);
8561- size_t a = getAlignOf (vt2, settings, accuracy);
8561+ size_t a = getAlignOf (vt2, settings, accuracy, SizeOf::Pointer );
85628562 if (n == 0 || a == 0 )
85638563 return accuracy == Accuracy::ExactOrZero ? 0 : total;
85648564 if (nBits == 0 ) {
@@ -8614,7 +8614,7 @@ size_t ValueType::getSizeOf( const Settings& settings, Accuracy accuracy, SizeOf
86148614 if (accuracy == Accuracy::ExactOrZero && total == 0 && !result.success )
86158615 return 0 ;
86168616 total = std::max (size_t {1 }, total);
8617- size_t align = getAlignOf (*this , settings, accuracy);
8617+ size_t align = getAlignOf (*this , settings, accuracy, sizeOf );
86188618 if (align == 0 )
86198619 return accuracy == Accuracy::ExactOrZero ? 0 : total;
86208620 total += (align - (total % align)) % align;
0 commit comments