From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653652422101.tru64-unix-managers.marc@archive.invalid> From: Tobias Ernst Date: Fri, 27 Jul 2001 15:15:25 +0000 To: tru64-unix-managers Subject: cxx 6.4 optimizer problem X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653652422101 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--AhhlLboLdkugWU4S" --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi! I think I have encountered a bug in this compiler from CXX64T01.tar: Compaq C++ T6.4-001 for Digital UNIX V5.0 (Rev. 910) Compiler Driver T6.4-001 (cxx) cxx Driver I thought this was the latest cxx compiler from Compaq, but now I am not so sure, since I see that for version 6.32 there are newer tar files available as for this 6.4 version !? Which one should I be using? Is T6.4-001 a beta test version? If so, where to report bugs? The bug is as follows: Use the .cc file found below and compile it using cxx -fast -O4 -tune host -assume noaccuracy_sensitive -MD \ -nopure_cname -noimplicit_include test.cc The output of the program should be "7.7", but if compiled as shown above, it is "NaNQ". The correct result of 7.7 is obtained when using -O3 instead of -O4, or when removing the comment signs before the one "clog <<" statement as seen in the source, or when using cxx V6.3-001 instead. Kind Regards, Tobias Ernst. --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="test.cc" #include #include #include #define NDIM 1 template struct Range { Range(OP &op): min(numeric_limits::max()), max(-numeric_limits::max()), f(op) {} template inline void operator()(const IDX &v) { if (f(v)max) max = f(v); } T min, max; protected: OP &f; }; class myidx { public: myidx(const int &i) : idx(i) {} myidx() : idx(0) {} const int operator[](int i) const { assert(i==0); return idx; } int &operator[](int i) { assert(i==0); return idx; } protected: int idx; }; struct myop { myop(double *p) { arr = p; } double operator()(const myidx &i) { return arr[i[0]]; } protected: double *arr; }; template static inline void for_each(const IDX b, const IDX e, OP &op) { ForEach fe(b,e,op); fe(); } template struct ForEach; template struct ForEach<1,IDX,OP> { ForEach(const IDX &begin, const IDX &end, OP &op): b(begin[0]), e(end[0]), fop(op) {} inline void operator()() { for(v[0]=b; v[0] static inline void range(const IDX begin, const IDX end, OP op, T &min, T &max) { Range range_op(op); for_each(begin, end, range_op); min = range_op.min; max = range_op.max; } template inline const T& PTmax(const T& a, const T& b) { return (a > b) ? a : b; } template inline T PTabs(const T& a) { return (a < 0? -a:a); } int main(void) { double array[]={2.2,1.1,3.3,7.7}; static myop myop1(array); double v_div,min,max; range(myidx(0),myidx(4),myop1,min,max); // If you add the following line, the code will work with -O4 as // well. If you do not add the followign line, the code will fail // with -O4 // clog << max << endl; v_div = max = PTmax(PTabs(min),max); clog << max << endl; } --AhhlLboLdkugWU4S--