robinrowe/libunistd

poll()'s counting seems to increment the pointer instead of the value

Closed this issue · 2 comments

*readerCount++;

Simplified demo of what I think is happening: http://cpp.sh/9tyco

*readerCount++ seems like it should be (*readerCount)++ to increment the value, not the pointer. Same for writerCount.

I used VS2013, but the cpp.sh snippet uses GCC 4.9.2.

I agree with @tankorsmash . Same is true for *writerCount++.

Postfix ++ has higher precedence than dereference * so it's being evaluated as *(readerCount++) and readerCount is a pointer on the stack.

Fixed. Thanks for the bug report.