Tuesday, September 2, 2008

When good compilers go BAD! A sorry tale of unhelpfulness from GCC

I've just added a new inserter class, w2m, to the world's fastest logging API library, Pantheios, in leiu of the widestring support that'll come in version 1.1+.

The initial implementation of the class uses STLSoft's auto_buffer, to be especially efficient in the case where the length of the string to be converted falls below a threshold - 64 in this case.

As with all other inserter classes, it does not provide copy semantics, neither copy constructor nor copy assignment operator.

All is well until I try to compile with GCC, which "helpfully" informs me that it can't generate a copy-constructor. (auto_buffer does not define a copy-constructor by design; you can read about why in section 16.2.3 of Extended STL, volume 1. Somewhat surprising that, given that I'd expressly told it not to try, by declaring, but not defining said copy constructor.

So, I've now got to spend a couple of hours implementing some custom memory management code to ensure portability. Great!

No comments: