Opened 3 years ago
Closed 3 years ago
#2675 closed Bug (fixed)
Incorrect evaluation of arithmetic expressions passed as argument to preprocessor macro 'A2D'
Reported by: | smueller | Owned by: | systeam |
---|---|---|---|
Priority: | normal | Milestone: | 2021 WP |
Component: | MULTIPLE | Version: | trunk |
Severity: | minor | Keywords: | CPP, macro |
Cc: |
Description (last modified by smueller)
Context
For nn_hls=1, the preprocessor macro A2D(nn_hls-1) evaluates to a different range than A2D(0).
Analysis
The argument of the A2D macro is not protected when used in the arithmetical expression that defines the range. As a result, for nn_hls=1, A2D(nn_hls-1) evaluates as ntsi-2:ntei,ntsj-2:ntej, which differs from the range represented by A2D(0) (ntsi:ntei,ntsj:ntej).
Fix
-
src/OCE/do_loop_substitute.h90
60 60 61 61 #define DO_2D(L, R, B, T) DO jj = ntsj-(B), ntej+(T) ; DO ji = ntsi-(L), ntei+(R) 62 62 #define DO_2D_OVR(L, R, B, T) DO_2D(L-(L+R)*nthl, R-(R+L)*nthr, B-(B+T)*nthb, T-(T+B)*ntht) 63 #define A1Di(H) ntsi- H:ntei+H64 #define A1Dj(H) ntsj- H:ntej+H63 #define A1Di(H) ntsi-(H):ntei+(H) 64 #define A1Dj(H) ntsj-(H):ntej+(H) 65 65 #define A2D(H) A1Di(H),A1Dj(H) 66 66 #define A1Di_T(T) (ntsi-nn_hls-1)*T+1: 67 67 #define A1Dj_T(T) (ntsj-nn_hls-1)*T+1:
should protect the argument of the A2D macro.
Commit History (0)
(No commits)
Change History (2)
comment:1 Changed 3 years ago by smueller
- Description modified (diff)
comment:2 Changed 3 years ago by smueller
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
Fixed with changeset [14903] in the context of task #2600.