PR libstdc++/81808
* testsuite/27_io/basic_fstream/53984.cc: Adjust test for targets
that allow opening a directory as a FILE and reading from it.
From-SVN: r251041
+2017-08-11 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/81808
+ * testsuite/27_io/basic_fstream/53984.cc: Adjust test for targets
+ that allow opening a directory as a FILE and reading from it.
+
2017-08-09 Jonathan Wakely <jwakely@redhat.com>
* include/std/type_traits (_GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP):
// { dg-require-fileio "" }
+// PR libstdc++/53984
+
#include <fstream>
#include <testsuite_hooks.h>
std::ifstream in(".");
if (in)
{
+ char c;
+ if (in.get(c))
+ {
+ // Reading a directory doesn't produce an error on this target
+ // so the formatted input functions below wouldn't fail anyway
+ // (see PR libstdc++/81808).
+ return;
+ }
int x;
+ in.clear();
+ // Formatted input function should set badbit, but not throw:
in >> x;
VERIFY( in.bad() );
+
+ in.clear();
+ in.exceptions(std::ios::badbit);
+ try
+ {
+ // Formatted input function should set badbit, and throw:
+ in >> x;
+ VERIFY( false );
+ }
+ catch (const std::exception&)
+ {
+ VERIFY( in.bad() );
+ }
}
}