This is my first question, sorry if it will be a bad formulated or bad one in general.
I have the following code:
volatile bool is_ordered = false;
while (!is_ordered)
{
is_ordered = true;
for (FieldOp& op : ordered_operator)
{
while (!op.left_chain.empty() && op.left_chain.back() > 0)
{
is_ordered = false;
op.CommuteRight(ordered_operator);
}
if (!is_ordered)
{
break;
}
}
}
ordered_operator
variable is a vector, CommuteRight()
method can change it by pushing back some element. As well as I know it can cause deallocation and copying of all elements to a new bigger block of memory. Because I have a break statement to start over with a new vector.
However, somehow I am getting segmentation fault error at while-loop condition. I also have is_ordered
is being equal to be false and &op
not pointing anywhere, so this is where segfault comes from I guess. I don`t understand how is it possible reach here and not hit break
after the while loop.
I make is_ordered false volatile and then turned off all of my optimizations and it didn’t help.
Lakorette is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.