I have the following c++ which previously worked on windows using a different compiler and on the w3schools compiler in browser.
#include "library.h"
#include <iostream>
void cluster(double* X, int Ntrj, int Nd, int Ngrid){
int strides[Nd], coords[Nd];
int* pstrides = &(strides[Nd-1]);
int* pcoords = &(coords[0]);
strides[Nd-1] = 1;
//std::cout << *pstrides << std::endl;
for (int i = Nd-2; i >=0 ; i--){
*(--pstrides) = *pstrides*Ngrid;
//std::cout << *pstrides << std::endl;
}
}
Compiling with g++ on macos I get the following error,
warning: unsequenced modification and access to 'pstrides' [-Wunsequenced]
*(--pstrides) = *pstrides*Ngrid;
^ ~~~~~~~~
I do not understand why this compiles in some cases and why in others it doesn't. I am c++ noob so any help would be appreciated. Thanks.