Menu

#240 Error in TISArrayAsVector::Add

6.34
closed
Internal (141)
1
2014-03-06
2013-07-02
No

There is an error in the algorithme of TISArrayAsVector::Add(T* t). The comparaison i made on adresses not on pointed elements. See below the extract of code.

bool Add(T* t) {
        /* incorrect algorithm
            int i = size() - 1;
            push_back(t);
            while (0 <= i && t < at(i)) {
                    at(i+1) = at(i);
                    --i;
            }
            if (i < (size() - 2)) {
                    at(i+1) = t;
            }*/
        // fix by Ruben P
        iterator i=begin();
        while(i!=end() && t>(*i))
            i++;

        if (i==end())
            push_back(t);
        else
            insert(i, t);

        return true;
}

The correction is :

bool Add(T* t) {
    // Fix by Parsys Telemedecine.
    if (t != 0)
    {
        iterator i=begin();
        while(i!=end() && (*t)>(*(*i)))
            i++;

        if (i==end())
            push_back(t);
        else
            insert(i, t);

        return true;
    }

    return false;
}

Related

Discussion: Array replacement
Discussion: Array replacement

Discussion

  • Vidar Hasfjord

    Vidar Hasfjord - 2013-07-13
    • labels: --> Internal
    • Group: 6.30.12 --> unspecified
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2013-08-15
    • status: open --> pending
    • assigned_to: Vidar Hasfjord
    • Group: unspecified --> 6.34

    The proposed fix was applied in [r1872].

     

    Related

    Commit: [r1872]


    Last edit: Vidar Hasfjord 2013-08-15
  • Ognyan Chernokozhev

    Hi

    Is there any reason not to include this fix in 6.32.6?

    Jogy

     
  • Vidar Hasfjord

    Vidar Hasfjord - 2013-09-06

    Hi Jogy,

    Is there any reason not to include this fix in 6.32.6?

    As far as I see, it breaks binary compatibility. We are not guaranteed that a call to the Add function actually calls the OWLNext DLL. The function may have been inlined, or otherwise instantiated or optimised, in the client application.

     
  • Vidar Hasfjord

    Vidar Hasfjord - 2014-03-06
    • Status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB