The code is fine. (and, interestingly enough, so is libc++)
This turns out to be a bug in clang; in fact, recent versions of clang crash when attempting to compile this code.
A patch fixing this in clang is currently being tested and will be part of the 3.4 release. If you can't wait that long, then you should be able to get a fixed version of clang "really soon now" if you are willing to build it from source.
Thanks to Alp from Nuanti for tracking down the clang bug.