[libc++] ios_base and exceptions

I think I've found a bug, what's the expected output of this program?

#include <sstream>
#include <iostream>

void test_iostate(std::ios_base::iostate state)
{
    char c;
    std::stringstream ss;
    try
    {
       ss.exceptions(state);
       ss >> c;
       std::cout << "Didn't throw\n";
    }
    catch(std::ios_base::failure const& ex)
    {
       std::cout << "Threw: " << ex.what() << "\n";
    }
}
int main()
{
    test_iostate(std::ios_base::eofbit);
    test_iostate(std::ios_base::badbit);
    test_iostate(std::ios_base::failbit);
    test_iostate(std::ios_base::eofbit|std::ios_base::badbit);
    test_iostate(std::ios_base::eofbit|std::ios_base::failbit);
    test_iostate(std::ios_base::badbit|std::ios_base::failbit);
test_iostate(std::ios_base::eofbit|std::ios_base::badbit|std::ios_base::failbit);
}

$ clang++ io_fail.cpp -stdlib=libc++ -lc++abi
$ ./a.out
Didn't throw
Threw: ios_base::clear: unspecified iostream_category error
Didn't throw
Threw: ios_base::clear: unspecified iostream_category error

$ clang++ io_fail.cpp
$ ./a.out
Threw: basic_ios::clear
Didn't throw
Threw: basic_ios::clear

Ben

I think I've found a bug, what's the expected output of this program?

I think you’re right, Ben.
Please file a bug at:
  http://www.llvm.org/bugs

Feel free to assign it to me.

— Marshall

That does sound like a particularly dark corner. Apologies for the misdirection.

Ben