The attached patches fix http://gcc.gnu.org/PR52822, and have been tested with `make check-c++` on linux-x86_64. The trunk patch applies and tests cleanly on gcc-4_7-branch. The gcc-4_6-branch patch is significantly simpler, as Paolo suggested on the bug.
The test is still inadequate, but given that there's no way to force get_temporary_buffer to return a short buffer, I'm not sure how to improve it. It might be possible to use set_memory_limits(), but that would require a very complex test program to make sure exactly the right operator new call fails. Jeffrey Yasskin
pr52822_trunk.patch
Description: Binary data
pr52822_gcc46.patch
Description: Binary data