Hi folks,
When I develop s/w, I typically try to avoid ambiguous statements like the following due to possible issues with operator precedence.
Code:
if (--ptr->count == 0)
{
...
}
After referring to the following
document, I'm still unclear as to whether the pre-decrement operator or the pointer-dereference operator have the same precedence(when reading the code left-to-right), or if the decrement operator has precedence over the pointer dereference operator.
I'm debugging some code (for work-related purposes), and my application is seg-faulting at a line very similar to what I have described above. Can someone please clarify my doubts about operator precedence?
My gut feeling is that the code should have written as:
Code:
if (--(ptr->count) == 0)
{
...
}