The value returned by sync is incorrect.
According to the specs:
Returns zero, which indicates success. A value of -1 would indicate failure.
On failure you return EOF. Yes I get that it is -1. But your making assumptions. Follow specs to the letter.
Things like this scare me:
I have been bitten a couple of times were macros expand to more than a single statement. Which renders the block incorrect. As a result I always use '{}' for sub blocks. I recommend it for everything it will prevent those impossible to find errors.
Since we now live in 2014 (nearly 2015). You should be using the modern version of the compiler. So add override to functions that override virtual functions.
int overflow(int ch = EOF) override;
int sync() override;
Definitely worth overriding the method streamsize xsputn (const char* s, streamsize n);