[cfe-dev] [libc++] ios_base and exceptions
Marshall Clow
mclow.lists at gmail.com
Tue Apr 22 14:20:35 PDT 2014
On Apr 22, 2014, at 8:23 AM, Ben Pope <benpope81 at gmail.com> wrote:
> 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
>
> #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
> Didn't throw
> Didn't throw
> Threw: ios_base::clear: unspecified iostream_category error
> Didn't throw
> Threw: ios_base::clear: unspecified iostream_category error
> 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
> Threw: basic_ios::clear
> Threw: basic_ios::clear
> Threw: basic_ios::clear
> Threw: basic_ios::clear
>
> Ben
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list