The recent discussion motivated me to look into the sources,
and I've noticed something strange.

        class num : public virtual Garbageable {
           private:
            int fType;
            union {
                int    i;
                double f;
            } fData;

           public:
            // constructors
            num(int x = 0) : fType(0) { fData.i = x; }
            num(double x) : fType(1) { fData.f = x; }
            num(const num& n) : fType(n.fType) { fData.i = n.fData.i; }

but the last constructor is wrong, isn't it?

        fData.i = n.fData.i;

is only correct if n.fType == 0, right?

The same for "==" and "!=" operators. I guess these methods are not used,
so perhaps the patch below makes sense? Before they find a user.

Oleg.
---

--- x/compiler/tlib/num.hh
+++ x/compiler/tlib/num.hh
@@ -70,7 +70,6 @@ class num : public virtual Garbageable {
     // constructors
     num(int x = 0) : fType(0) { fData.i = x; }
     num(double x) : fType(1) { fData.f = x; }
-    num(const num& n) : fType(n.fType) { fData.i = n.fData.i; }
 
     num& operator=(int n)
     {
@@ -89,10 +88,6 @@ class num : public virtual Garbageable {
     int type() const { return fType; }
     operator int() const { return (fType) ? int(fData.f) : fData.i; }
     operator double() const { return (fType) ? fData.f : double(fData.i); }
-
-    // predicats
-    bool operator==(const num& n) const { return fType == n.fType && fData.i 
== n.fData.i; }
-    bool operator!=(const num& n) const { return fType != n.fType || fData.i 
!= n.fData.i; }
 };
 
 inline int isfloat(const num& n)



_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel

Reply via email to