As a followup: The original code sample I posted was rediculously byzantine. I was testing several things at the same time. The following code fragment more exhibits the problem more simply. Simply use this as foo.cc instead of the original: