Skip to content

Commit 21e06d2

Browse files
committed
Prevent the pre-computation of log10(new_npets-1) in optimized mode
by making new_npets volatile. This way, even when user specifies trapping on all FPEs, there isn't an issue, even for new_npets==1. This is solution leads to cleaner code than the initial work-around solution committed under hash 1fd5b0.
1 parent fe1c638 commit 21e06d2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Infrastructure/VM/src/ESMCI_VMKernel.C

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,9 @@ void *VMK::startup(class VMKPlan *vmp, void *(fctp)(void *, void *),
18741874
#endif
18751875
// next, determine new_npets and new_mypet_base ...
18761876
int new_mypet_base=0;
1877-
int new_npets=0;
1877+
volatile int new_npets=0; // volatile to prevent precompute of log10() below
1878+
// in optimized mode or else might trigger SIGFPE
1879+
// for new_npets==1 if user code sets FPE trapping
18781880
int found_my_pet_flag = 0;
18791881
for (int ii=0; ii<npets; ii++){
18801882
int i = vmp->petlist[ii]; // indirection to preserve petlist order

0 commit comments

Comments
 (0)