Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 426
    • Issues 426
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #1593
Closed
Open
Issue created Feb 13, 2020 by Vaggelis Papoutsis@vaggelispDeveloper

BUG: FixedList<T, N>::find may be stuck in an infinite loop

Summary

In FixedList<T, N>::find, the pos label is not incremented in the following while loop

    if (pos >= 0)                                                                                     
    {                                                                                                 
        List_CONST_ACCESS(T, *this, list);                                                            
                                                                                                      
        while (pos < label(N))                                                                        
        {                                                                                             
            if (list[pos] == val)                                                                     
            {                                                                                         
                return pos;                                                                           
            }                                                                          
        }                                                                                             
    }  

Hence, if val is not equal to the initial list[pos], the code will be stuck in an infinite loop.

Possible fixes

Incrementing pos inside the loop should restore the expected behavior.

    if (pos >= 0)                                                                                     
    {                                                                                                 
        List_CONST_ACCESS(T, *this, list);                                                            
                                                                                                      
        while (pos < label(N))                                                                        
        {                                                                                             
            if (list[pos] == val)                                                                     
            {                                                                                         
                return pos;                                                                           
            }                                                                          
            ++pos;
        }                                                                                             
    }  
Assignee
Assign to
Time tracking