Skip to content

Commit 0543e23

Browse files
author
Charlie Root
committed
fix division by zero in C++ compiler
1 parent 0e96734 commit 0543e23

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bld/plusplus/c/datainit.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,11 @@ static bool dataInitCheckHugeAlign( TYPE type )
383383
base_type = ArrayType( type );
384384
}
385385
base_size = CgMemorySize( type );
386-
return( ((TARGET_UINT_MAX + 1) % base_size) != 0 );
386+
#if _CPU == 8086
387+
return( ( base_size % (TARGET_UINT_MAX + 1) ) != 0 );
388+
#else
389+
return( base_size != 0 );
390+
#endif
387391
}
388392

389393
static TYPE dtorableObjectType( // GET TYPE OF DTORABLE OBJECT (AT ROOT) ELEMENT
@@ -1319,8 +1323,12 @@ static void dataInitRunTimeCallHuge( target_size_t position, target_size_t diff
13191323

13201324
while( diff != 0 && currInit->state != DS_ERROR ) {
13211325
dataInitCheckHugeSegment( position );
1326+
#if _CPU == 8086
13221327
position %= (TARGET_UINT_MAX + 1);
13231328
increment = TARGET_UINT_MAX + 1 - position;
1329+
#else
1330+
increment = - position;
1331+
#endif
13241332
if( increment > diff ) {
13251333
increment = diff;
13261334
}
@@ -1572,8 +1580,12 @@ static void dataInitPadOutHuge( INITIALIZE_INFO *top )
15721580
position = top->base + top->offset;
15731581
while( diff != 0 ) {
15741582
dataInitCheckHugeSegment( position );
1583+
#if _CPU == 8086
15751584
position %= (TARGET_UINT_MAX + 1);
15761585
increment = TARGET_UINT_MAX + 1 - position;
1586+
#else
1587+
increment = - position;
1588+
#endif
15771589
if( increment > diff ) {
15781590
increment = diff;
15791591
}

0 commit comments

Comments
 (0)