From the comments here, it looks like the code itself is alright, so I went ahead and reported it to gcc bugzilla.