Clang and __gnu_cxx::simd_fast_mersenne_twister_engine. SSE2 bug?

GCC 4.8 added an SSE2 optimized simd_fast_mersenne_twister_engine in the
__gnu_cxx namespace. I've been able to use this successfully with both GCC and
ICC, but when I use it with Clang, it doesn't give consistent results.

Here's a simple example:

jscott@saaz:/tmp$ cat sfmt.cpp
#include <stdio.h>
#include <random>
#include <ext/random>

int main (void)
{
  /* Construct an engine, and print the first word of output. */
  __gnu_cxx::sfmt19937 engine;
  uint32_t first_word = engine();
  printf("%08x\n", first_word);

  /* Reset the engine, and print the first word again. */
  engine.seed();
  uint32_t first_word_again = engine();
  printf("%08x\n", first_word_again);

  if (first_word != first_word_again)
  {
    printf("FAIL: values should match!\n");
    return 1;
  }

  return 0;
}

jscott@saaz:/tmp$ clang++ -std=c++11 sfmt.cpp -o sfmt
jscott@saaz:/tmp$ ./sfmt
02fafdb7
74994db7
FAIL: values should match!

With GCC it looks fine:

jscott@saaz:/tmp$ g++-4.8 -std=c++11 sfmt.cpp -o sfmt
jscott@saaz:/tmp$ ./sfmt
02ef8db7
02ef8db7

I also notice that if I disable SSE2, clang works fine:

jscott@saaz:/tmp$ clang++ -std=c++11 sfmt.cpp -o sfmt -mno-sse2
jscott@saaz:/tmp$ ./sfmt
02ef8db7
02ef8db7

Can a Clang expert tell me whether this is a bug in Clang? Or something else?

I'm using Clang 3.4 on x86_64.

Thanks,

John

Ah, this is <18323 – Clang++ 3.4 of Ubuntu 13.10 miscompiles simd_fast_mersenne_twister_engine of gcc 4.8.1.
There's a workaround there which fixes my test case as well.

Cheers,

John