* cxx 6.4 optimizer problem
@ 2001-07-27 15:15 Tobias Ernst
0 siblings, 0 replies; only message in thread
From: Tobias Ernst @ 2001-07-27 15:15 UTC (permalink / raw)
To: tru64-unix-managers
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="--AhhlLboLdkugWU4S", Size: 3390 bytes --]
--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 <limits>
#include <iostream>
#include <cassert>
#define NDIM 1
template<class OP, class T>
struct Range
{
Range(OP &op): min(numeric_limits<T>::max()),
max(-numeric_limits<T>::max()), f(op)
{}
template<class IDX>
inline void operator()(const IDX &v)
{
if (f(v)<min) min = f(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<class IDX, class OP>
static inline void for_each(const IDX b, const IDX e, OP &op)
{
ForEach<NDIM,IDX,OP> fe(b,e,op);
fe();
}
template<int N, class IDX, class OP> struct ForEach;
template<class IDX, class OP>
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]<e; ++v[0]) fop(v);
}
protected:
const int b,e;
OP &fop;
public:
IDX v;
};
template<class IDX, class OP, class T>
static inline void range(const IDX begin, const IDX end, OP op,
T &min, T &max)
{
Range<OP,T> range_op(op);
for_each(begin, end, range_op);
min = range_op.min;
max = range_op.max;
}
template <class T>
inline const T& PTmax(const T& a, const T& b)
{
return (a > b) ? a : b;
}
template <class T>
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, myop, double>(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--
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-07-27 15:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-27 15:15 cxx 6.4 optimizer problem Tobias Ernst
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox