New URL for NEMO forge!

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
#2675 (Incorrect evaluation of arithmetic expressions passed as argument to preprocessor macro 'A2D') – NEMO

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

Description (last modified by smueller)


For nn_hls=1, the preprocessor macro A2D(nn_hls-1) evaluates to a different range than A2D(0).


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).


  • src/OCE/do_loop_substitute.h90

    6161#define DO_2D(L, R, B, T) DO jj = ntsj-(B), ntej+(T) ; DO ji = ntsi-(L), ntei+(R) 
    6262#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+H 
    64 #define A1Dj(H) ntsj-H:ntej+H 
     63#define A1Di(H) ntsi-(H):ntei+(H) 
     64#define A1Dj(H) ntsj-(H):ntej+(H) 
    6565#define A2D(H) A1Di(H),A1Dj(H) 
    6666#define A1Di_T(T) (ntsi-nn_hls-1)*T+1: 
    6767#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

Fixed with changeset [14903] in the context of task #2600.

Note: See TracTickets for help on using tickets.