problem with seekg() on a wfstream

Hallo,

I'm having surprising problems trying to seek back
a wfstream after reading its contents.
I'm working on linux with the current llvm 'release_80'.

Here is the test.cpp and the input file:

#include <iostream>
#include <fstream>

int main( int argc, const char *argv[] )
{
  std::wfstream ws;
  std::wstring line;

  if( argc > 1 )
    ws.open( argv[1] );

  if( !ws.is_open() ) {
    std::wcout << L"errors opening the stream.\n";
    return -1;
  }

  std::wcout << L"read the file:\n";
  while( std::getline( ws, line ) )
    std::wcout << L"line: " << line << std::endl;

  std::wcout << L"done reading the file.\n";

  ws.clear();
  ws.seekg( 0 );

  std::wcout << L"read the file again:\n";
  while( std::getline( ws, line ) )
    std::wcout << L"line: " << line << std::endl;

  std::wcout << L"done reading the file again.\n";
  return 0;
};

The input file:

abc
1 2 3

Compiling the program with:

# make test CXX=clang++ CXXFLAGS="-O2 -march=native -stdlib=libc++
-std=c++17" LDFLAGS="-fuse-ld=lld"

And here are the results:

# ./test test.txt
read the file:
line: abc
line: 1 2 3
done reading the file.
read the file again:
done reading the file again.

The second time I want to read the file it does not work because the
wfstream is in 'fail' state after the call to seekg( 0 ).

The same source linked against the libstdc++ works as expected:

# make test CXX=clang++ CXXFLAGS="-O2 -march=native -stdlib=libstdc++
-std=c++17" LDFLAGS="-fuse-ld=lld"

# ./test test.txt
read the file:
line: abc
line: 1 2 3
done reading the file.
read the file again:
line: abc
line: 1 2 3
done reading the file again.

giorgio