View Issue Details

IDProjectCategoryView StatusLast Update
0001787OpenFOAMBugpublic2015-07-15 12:08
Reporteruser317Assigned Tohenry  
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSUbuntuOS Version13.10
Summary0001787: UList::swap and FixedList::swap are wrong
Descriptionthe code is wrong
Ulist.C line 92 to 99 in function UList::swap
    List_ACCESS(T, (*this), vp);
    List_ACCESS(T, a, ap);
    T tmp;
    List_FOR_ALL((*this), i)
        tmp = List_ELEM((*this), vp, i);
        List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
        List_ELEM(a, ap, i) = tmp;
    List_END_FOR_ALL

should be

    List_ACCESS(T, (*this), vp);
    List_ACCESS(T, a, ap);
    T tmp;
    List_FOR_ALL((*this), i)
        tmp = List_ELEM((*this), vp, i);
        --vp;
        List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
        --ap;
        List_ELEM(a, ap, i) = tmp;
    List_END_FOR_ALL
because
#define List_ELEM(f, fp, i) (*fp++)
in ListLoopM.H line65
the same to FixedList::swap
TagsNo tags attached.

Activities

henry

2015-07-15 10:51

manager   ~0005088

Thank you for the bug-report, analysis and proposed fix. Rather than hard-code the pointer decrements, which is not appropriate if the vector machine option is used, I have implemented List_CELEM which returns the current element without incrementing the pointer. This is running fine in OpenFOAM-dev and I will transfer the changes to OpenFOAM-2.4.x shortly and push both.

henry

2015-07-15 12:08

manager   ~0005089

Resolved by commit 98302e5c5044f473b35cbd50233b941c741dca2a

Issue History

Date Modified Username Field Change
2015-07-15 09:40 user317 New Issue
2015-07-15 10:51 henry Note Added: 0005088
2015-07-15 12:08 henry Note Added: 0005089
2015-07-15 12:08 henry Status new => resolved
2015-07-15 12:08 henry Resolution open => fixed
2015-07-15 12:08 henry Assigned To => henry