A friend posed a question this evening as to why the following code should not be accepted as valid C++03:

This code is accepted by clang, but rejected by (at least) g++ 4.4-4.6 with the diagnostic:

error: no matching function for call to `fill(unsigned char*&, unsigned char*, Foo::<anonymous enum>)`

At first I blamed too many implicit conversion steps but, after a short discussion, the answer turned out to be quite simple: the enum is anonymous, and std::fill is a template whose third implicit argument here is an anonymous type… which is impossible in C++03.

If we pass the value as the int that it was always destined to become (before eventually becoming a char), we get:

Which behaves as one expects on all toolchains.

C++0x will accept anonymous types as template parameters but, for now, clang appears to be in error. At least it's filed. 🙂