* [v3] c++0x <system_error> CD updates
@ 2008-10-14 15:09 Chris Fairles
2008-10-14 15:37 ` Paolo Carlini
0 siblings, 1 reply; 8+ messages in thread
From: Chris Fairles @ 2008-10-14 15:09 UTC (permalink / raw)
To: Gcc Patch List, libstdc++
[-- Attachment #1: Type: text/plain, Size: 590 bytes --]
Attached is a draft patch of the CD changes to <system_error> (from
n2798). Its not ready for mainline as there are still a few
regressions due to segfaulting category().name().
FAIL: 27_io/basic_ostream/inserters_other/char/error_code.cc execution test
FAIL: 27_io/basic_ostream/inserters_other/wchar_t/error_code.cc execution test
FAIL: ext/mt_allocator/deallocate_local_thread-5.cc execution test
FAIL: ext/mt_allocator/deallocate_local_thread-7.cc execution test
Besides those, feel free to comment/review. I'll post an updated patch
once I figure out those segfaults.
Cheers,
Chris
[-- Attachment #2: system_error.patch.txt --]
[-- Type: text/plain, Size: 26958 bytes --]
Index: src/system_error.cc
===================================================================
--- src/system_error.cc (revision 141102)
+++ src/system_error.cc (working copy)
@@ -36,15 +36,12 @@
namespace
{
using std::string;
-
- struct gnu_error_category : public std::error_category
+
+ struct generic_error_category : public std::error_category
{
virtual const char*
name() const
- {
- const char* s = "GNU";
- return s;
- }
+ { return "generic"; }
virtual string
message(int i) const
@@ -55,16 +52,32 @@
}
};
- const gnu_error_category gnu_category;
+ struct system_error_category : public std::error_category
+ {
+ virtual const char*
+ name() const
+ { return "system"; }
+
+ virtual string
+ message(int i) const
+ {
+ // XXX locale issues: how does one get or set loc.
+ // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc)
+ return string(strerror(i));
+ }
+ };
+
+ const generic_error_category generic_category;
+ const system_error_category system_category;
}
_GLIBCXX_BEGIN_NAMESPACE(std)
const error_category&
- get_posix_category() { return gnu_category; }
+ get_generic_category() { return generic_category; }
const error_category&
- get_system_category() { return gnu_category; }
+ get_system_category() { return system_category; }
system_error::~system_error() throw() { }
Index: include/std/system_error
===================================================================
--- include/std/system_error (revision 141102)
+++ include/std/system_error (working copy)
@@ -57,7 +57,7 @@
struct is_error_code_enum : public false_type { };
template<>
- struct is_error_code_enum<posix_error::posix_errno>
+ struct is_error_code_enum<errc>
: public true_type { };
/// is_error_condition_enum
@@ -65,15 +65,22 @@
struct is_error_condition_enum : public false_type { };
template<>
- struct is_error_condition_enum<posix_error::posix_errno>
+ struct is_error_condition_enum<errc>
: public true_type { };
/// error_category
- struct error_category
+ class error_category
{
- error_category() { }
+ protected:
+ error_category() = default;
+ public:
+ virtual ~error_category() { }
+
+ error_category(const error_category&) = delete;
+ error_category& operator=(const error_category&) = delete;
+
virtual const char*
name() const = 0;
@@ -100,19 +107,13 @@
bool
operator!=(const error_category& __other) const
{ return this != &__other; }
-
- private:
- error_category(const error_category&);
-
- error_category&
- operator=(const error_category&);
};
- const error_category& get_posix_category();
+ const error_category& get_generic_category();
const error_category& get_system_category();
- static const error_category& posix_category = get_posix_category();
static const error_category& system_category = get_system_category();
+ static const error_category& generic_category = get_generic_category();
/// error_code
// Implementation-specific error identification
@@ -127,7 +128,7 @@
template<typename _ErrorCodeEnum>
error_code(_ErrorCodeEnum __e,
typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0)
- : _M_value(__e), _M_cat(&posix_category)
+ :_M_value(static_cast<int>(__e)), _M_cat(&generic_category)
{ }
void
@@ -150,8 +151,8 @@
error_code&>::type
operator=(_ErrorCodeEnum __e)
{
- _M_value = __e;
- _M_cat = &posix_category;
+ _M_value = static_cast<int>(__e);
+ _M_cat = &generic_category;
return *this;
}
@@ -184,7 +185,11 @@
const error_category* _M_cat;
};
- // 19.4.2.5 non-member functions
+ // 19.4.2.6 non-member functions
+ inline error_code
+ make_error_code(errc __e)
+ { return error_code(static_cast<int>(__e), generic_category); }
+
inline bool
operator<(const error_code& __lhs, const error_code& __rhs)
{
@@ -203,7 +208,7 @@
// Portable error identification
struct error_condition
{
- error_condition() : _M_value(0), _M_cat(&posix_category) { }
+ error_condition() : _M_value(0), _M_cat(&generic_category) { }
error_condition(int __v, const error_category& __cat)
: _M_value(__v), _M_cat(&__cat) { }
@@ -212,7 +217,7 @@
error_condition(_ErrorConditionEnum __e,
typename enable_if<is_error_condition_enum
<_ErrorConditionEnum>::value>::type* = 0)
- : _M_value(__e), _M_cat(&posix_category) { }
+ : _M_value(static_cast<int>(__e)), _M_cat(&generic_category) { }
void
assign(int __v, const error_category& __cat)
@@ -227,8 +232,8 @@
<_ErrorConditionEnum>::value, error_condition&>::type
operator=(_ErrorConditionEnum __e)
{
- _M_value = __e;
- _M_cat = &posix_category;
+ _M_value = static_cast<int>(__e);
+ _M_cat = &generic_category;
return *this;
}
@@ -236,7 +241,7 @@
clear()
{
_M_value = 0;
- _M_cat = &posix_category;
+ _M_cat = &generic_category;
}
// 19.4.3.4 observers
@@ -266,7 +271,11 @@
const error_category* _M_cat;
};
- // 19.4.3.5 non-member functions
+ // 19.4.3.6 non-member functions
+ inline error_condition
+ make_error_condition(errc __e)
+ { return error_condition(static_cast<int>(__e), generic_category); }
+
inline bool
operator<(const error_condition& __lhs, const error_condition& __rhs)
{
@@ -275,17 +284,6 @@
&& __lhs.value() < __rhs.value()));
}
- namespace posix_error
- {
- inline error_code
- make_error_code(posix_errno __e)
- { return error_code(__e, posix_category); }
-
- inline error_condition
- make_error_condition(posix_errno __e)
- { return error_condition(__e, posix_category); }
- }
-
// 19.4.4 Comparison operators
inline bool
operator==(const error_code& __lhs, const error_code& __rhs)
@@ -342,6 +340,16 @@
system_error(error_code __ec, const string& __what)
: runtime_error(__what), _M_code(__ec) { }
+
+ /*
+ * TODO: Add const char* ctors to all exceptions.
+ *
+ * system_error(error_code __ec, const char* __what)
+ * : runtime_error(__what), _M_code(__ec) { }
+ *
+ * system_error(int __v, const error_category& __ecat, const char* __what)
+ * : runtime_error(__what), _M_code(error_code(__v, __ecat)) { }
+ */
system_error(int __v, const error_category& __ecat)
: runtime_error(""), _M_code(error_code(__v, __ecat)) { }
Index: include/std/mutex
===================================================================
--- include/std/mutex (revision 141102)
+++ include/std/mutex (working copy)
@@ -489,9 +489,9 @@
lock()
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_device->lock();
@@ -503,9 +503,9 @@
try_lock()
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_owns = _M_device->try_lock();
@@ -518,9 +518,9 @@
try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_owns = _M_device->try_lock_until(__atime);
@@ -533,9 +533,9 @@
try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_owns = _M_device->try_lock_for(__rtime);
@@ -547,7 +547,7 @@
unlock()
{
if (!_M_owns)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_device)
{
_M_device->unlock();
Index: testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
===================================================================
--- testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc (revision 141102)
+++ testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc (working copy)
@@ -33,7 +33,7 @@
wchar_t buf[64];
error_code e1;
- error_code e2(posix_error::bad_address);
+ error_code e2(errc::bad_address);
wstring s, s1, s2;
{
Index: testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc
===================================================================
--- testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc (revision 141102)
+++ testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc (working copy)
@@ -33,7 +33,7 @@
char buf[64];
error_code e1;
- error_code e2(posix_error::bad_address);
+ error_code e2(errc::bad_address);
string s, s1, s2;
{
Index: testsuite/19_diagnostics/error_condition/cons/1.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/cons/1.cc (revision 141102)
+++ testsuite/19_diagnostics/error_condition/cons/1.cc (working copy)
@@ -28,7 +28,7 @@
// 1
std::error_condition e1;
VERIFY( e1.value() == 0 );
- VERIFY( e1.category() == std::posix_category );
+ VERIFY( e1.category() == std::system_category );
// 2
const __gnu_test::test_category cat;
@@ -37,9 +37,9 @@
VERIFY( e2.category() == cat );
// 3
- std::error_condition e3(std::posix_error::operation_not_supported);
- VERIFY( e3.value() == int(std::posix_error::operation_not_supported) );
- VERIFY( e3.category() == std::posix_category );
+ std::error_condition e3(std::errc::operation_not_supported);
+ VERIFY( e3.value() == int(std::errc::operation_not_supported) );
+ VERIFY( e3.category() == std::system_category );
}
int main()
Index: testsuite/19_diagnostics/error_condition/operators/bool.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/operators/bool.cc (revision 141102)
+++ testsuite/19_diagnostics/error_condition/operators/bool.cc (working copy)
@@ -34,7 +34,7 @@
}
// 2
- std::error_condition e2(std::posix_error::operation_not_supported);
+ std::error_condition e2(std::errc::operation_not_supported);
if (e2)
{
VERIFY( true );
Index: testsuite/19_diagnostics/error_condition/operators/equal.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/operators/equal.cc (revision 141102)
+++ testsuite/19_diagnostics/error_condition/operators/equal.cc (working copy)
@@ -27,7 +27,7 @@
bool test __attribute__((unused)) = true;
std::error_condition e1;
- std::error_condition e2(std::posix_error::operation_not_supported);
+ std::error_condition e2(std::errc::operation_not_supported);
VERIFY( e1 == e1 );
VERIFY( !(e1 == e2) );
Index: testsuite/19_diagnostics/error_condition/operators/not_equal.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/operators/not_equal.cc (revision 141102)
+++ testsuite/19_diagnostics/error_condition/operators/not_equal.cc (working copy)
@@ -27,7 +27,7 @@
bool test __attribute__((unused)) = true;
std::error_condition e1;
- std::error_condition e2(std::posix_error::operation_not_supported);
+ std::error_condition e2(std::errc::operation_not_supported);
VERIFY( !(e1 != e1) );
VERIFY( e1 != e2 );
Index: testsuite/19_diagnostics/error_code/cons/1.cc
===================================================================
--- testsuite/19_diagnostics/error_code/cons/1.cc (revision 141102)
+++ testsuite/19_diagnostics/error_code/cons/1.cc (working copy)
@@ -38,9 +38,9 @@
VERIFY( e2.category() == cat );
// 3
- std::error_code e3(std::posix_error::operation_not_supported);
- VERIFY( e3.value() == int(std::posix_error::operation_not_supported) );
- VERIFY( e3.category() == std::posix_category );
+ std::error_code e3(std::errc::operation_not_supported);
+ VERIFY( e3.value() == int(std::errc::operation_not_supported) );
+ VERIFY( e3.category() == std::system_category );
return 0;
}
Index: testsuite/19_diagnostics/error_code/operators/bool.cc
===================================================================
--- testsuite/19_diagnostics/error_code/operators/bool.cc (revision 141102)
+++ testsuite/19_diagnostics/error_code/operators/bool.cc (working copy)
@@ -35,7 +35,7 @@
}
// 2
- std::error_code e2(std::posix_error::operation_not_supported);
+ std::error_code e2(std::errc::operation_not_supported);
if (e2)
{
VERIFY( true );
Index: testsuite/19_diagnostics/error_code/operators/equal.cc
===================================================================
--- testsuite/19_diagnostics/error_code/operators/equal.cc (revision 141102)
+++ testsuite/19_diagnostics/error_code/operators/equal.cc (working copy)
@@ -28,7 +28,7 @@
bool test __attribute__((unused)) = true;
std::error_code e1;
- std::error_code e2(std::posix_error::operation_not_supported);
+ std::error_code e2(std::errc::operation_not_supported);
VERIFY( e1 == e1 );
VERIFY( !(e1 == e2) );
Index: testsuite/19_diagnostics/error_code/operators/not_equal.cc
===================================================================
--- testsuite/19_diagnostics/error_code/operators/not_equal.cc (revision 141102)
+++ testsuite/19_diagnostics/error_code/operators/not_equal.cc (working copy)
@@ -28,7 +28,7 @@
bool test __attribute__((unused)) = true;
std::error_code e1;
- std::error_code e2(std::posix_error::operation_not_supported);
+ std::error_code e2(std::errc::operation_not_supported);
VERIFY( !(e1 != e1) );
VERIFY( e1 != e2 );
Index: testsuite/19_diagnostics/error_category/cons/copy_neg.cc
===================================================================
--- testsuite/19_diagnostics/error_category/cons/copy_neg.cc (revision 141102)
+++ testsuite/19_diagnostics/error_category/cons/copy_neg.cc (working copy)
@@ -33,7 +33,7 @@
return 0;
}
-// { dg-error "is private" "" { target *-*-* } 105 }
-// { dg-error "within this context" "" { target *-*-* } 40 }
+// { dg-error "deleted function" "" { target *-*-* } 81 }
+// { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "first required here" "" { target *-*-* } 31 }
// { dg-excess-errors "copy constructor" }
Index: testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc
===================================================================
--- testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc (revision 141102)
+++ testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc (working copy)
@@ -28,134 +28,133 @@
using std::error_category;
using std::system_category;
- using std::posix_error::posix_errno;
- using std::posix_error::address_family_not_supported;
- using std::posix_error::address_in_use;
- using std::posix_error::address_not_available;
- using std::posix_error::already_connected;
- using std::posix_error::argument_list_too_long;
- using std::posix_error::argument_out_of_domain;
- using std::posix_error::bad_address;
- using std::posix_error::bad_file_descriptor;
+ using std::errc::address_family_not_supported;
+ using std::errc::address_in_use;
+ using std::errc::address_not_available;
+ using std::errc::already_connected;
+ using std::errc::argument_list_too_long;
+ using std::errc::argument_out_of_domain;
+ using std::errc::bad_address;
+ using std::errc::bad_file_descriptor;
#ifdef _GLIBCXX_HAVE_EBADMSG
- using std::posix_error::bad_message;
+ using std::errc::bad_message;
#endif
- using std::posix_error::broken_pipe;
- using std::posix_error::connection_aborted;
- using std::posix_error::connection_already_in_progress;
- using std::posix_error::connection_refused;
- using std::posix_error::connection_reset;
- using std::posix_error::cross_device_link;
- using std::posix_error::destination_address_required;
- using std::posix_error::device_or_resource_busy;
- using std::posix_error::directory_not_empty;
- using std::posix_error::executable_format_error;
- using std::posix_error::file_exists;
- using std::posix_error::file_too_large;
- using std::posix_error::filename_too_long;
- using std::posix_error::function_not_supported;
- using std::posix_error::host_unreachable;
+ using std::errc::broken_pipe;
+ using std::errc::connection_aborted;
+ using std::errc::connection_already_in_progress;
+ using std::errc::connection_refused;
+ using std::errc::connection_reset;
+ using std::errc::cross_device_link;
+ using std::errc::destination_address_required;
+ using std::errc::device_or_resource_busy;
+ using std::errc::directory_not_empty;
+ using std::errc::executable_format_error;
+ using std::errc::file_exists;
+ using std::errc::file_too_large;
+ using std::errc::filename_too_long;
+ using std::errc::function_not_supported;
+ using std::errc::host_unreachable;
#ifdef _GLIBCXX_HAVE_EIDRM
- using std::posix_error::identifier_removed;
+ using std::errc::identifier_removed;
#endif
- using std::posix_error::illegal_byte_sequence;
- using std::posix_error::inappropriate_io_control_operation;
- using std::posix_error::interrupted;
- using std::posix_error::invalid_argument;
- using std::posix_error::invalid_seek;
- using std::posix_error::io_error;
- using std::posix_error::is_a_directory;
- using std::posix_error::message_size;
- using std::posix_error::network_down;
- using std::posix_error::network_reset;
- using std::posix_error::network_unreachable;
- using std::posix_error::no_buffer_space;
- using std::posix_error::no_child_process;
+ using std::errc::illegal_byte_sequence;
+ using std::errc::inappropriate_io_control_operation;
+ using std::errc::interrupted;
+ using std::errc::invalid_argument;
+ using std::errc::invalid_seek;
+ using std::errc::io_error;
+ using std::errc::is_a_directory;
+ using std::errc::message_size;
+ using std::errc::network_down;
+ using std::errc::network_reset;
+ using std::errc::network_unreachable;
+ using std::errc::no_buffer_space;
+ using std::errc::no_child_process;
#ifdef _GLIBCXX_HAVE_ENOLINK
- using std::posix_error::no_link;
+ using std::errc::no_link;
#endif
- using std::posix_error::no_lock_available;
+ using std::errc::no_lock_available;
#ifdef _GLIBCXX_HAVE_ENODATA
- using std::posix_error::no_message_available;
+ using std::errc::no_message_available;
#endif
- using std::posix_error::no_message;
- using std::posix_error::no_posix_equivalent;
- using std::posix_error::no_protocol_option;
- using std::posix_error::no_space_on_device;
+ using std::errc::no_message;
+ using std::errc::no_posix_equivalent;
+ using std::errc::no_protocol_option;
+ using std::errc::no_space_on_device;
#ifdef _GLIBCXX_HAVE_ENOSR
- using std::posix_error::no_stream_resources;
+ using std::errc::no_stream_resources;
#endif
- using std::posix_error::no_such_device_or_address;
- using std::posix_error::no_such_device;
- using std::posix_error::no_such_file_or_directory;
- using std::posix_error::no_such_process;
- using std::posix_error::not_a_directory;
- using std::posix_error::not_a_socket;
+ using std::errc::no_such_device_or_address;
+ using std::errc::no_such_device;
+ using std::errc::no_such_file_or_directory;
+ using std::errc::no_such_process;
+ using std::errc::not_a_directory;
+ using std::errc::not_a_socket;
#ifdef _GLIBCXX_HAVE_ENOSTR
- using std::posix_error::not_a_stream;
+ using std::errc::not_a_stream;
#endif
- using std::posix_error::not_connected;
- using std::posix_error::not_enough_memory;
- using std::posix_error::not_supported;
+ using std::errc::not_connected;
+ using std::errc::not_enough_memory;
+ using std::errc::not_supported;
#ifdef _GLIBCXX_HAVE_ECANCELED
- using std::posix_error::operation_canceled;
+ using std::errc::operation_canceled;
#endif
- using std::posix_error::operation_in_progress;
- using std::posix_error::operation_not_permitted;
- using std::posix_error::operation_not_supported;
- using std::posix_error::operation_would_block;
+ using std::errc::operation_in_progress;
+ using std::errc::operation_not_permitted;
+ using std::errc::operation_not_supported;
+ using std::errc::operation_would_block;
#ifdef _GLIBCXX_HAVE_EOWNERDEAD
- using std::posix_error::owner_dead;
+ using std::errc::owner_dead;
#endif
- using std::posix_error::permission_denied;
+ using std::errc::permission_denied;
#ifdef _GLIBCXX_HAVE_EPROTO
- using std::posix_error::protocol_error;
+ using std::errc::protocol_error;
#endif
- using std::posix_error::protocol_not_supported;
- using std::posix_error::read_only_file_system;
- using std::posix_error::resource_deadlock_would_occur;
- using std::posix_error::resource_unavailable_try_again;
- using std::posix_error::result_out_of_range;
+ using std::errc::protocol_not_supported;
+ using std::errc::read_only_file_system;
+ using std::errc::resource_deadlock_would_occur;
+ using std::errc::resource_unavailable_try_again;
+ using std::errc::result_out_of_range;
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
- using std::posix_error::state_not_recoverable;
+ using std::errc::state_not_recoverable;
#endif
#ifdef _GLIBCXX_HAVE_ETIME
- using std::posix_error::stream_timeout;
+ using std::errc::stream_timeout;
#endif
#ifdef _GLIBCXX_HAVE_ETXTBSY
- using std::posix_error::text_file_busy;
+ using std::errc::text_file_busy;
#endif
- using std::posix_error::timed_out;
- using std::posix_error::too_many_files_open_in_system;
- using std::posix_error::too_many_files_open;
- using std::posix_error::too_many_links;
- using std::posix_error::too_many_synbolic_link_levels;
+ using std::errc::timed_out;
+ using std::errc::too_many_files_open_in_system;
+ using std::errc::too_many_files_open;
+ using std::errc::too_many_links;
+ using std::errc::too_many_synbolic_link_levels;
#ifdef _GLIBCXX_HAVE_EOVERFLOW
- using std::posix_error::value_too_large;
+ using std::errc::value_too_large;
#endif
- using std::posix_error::wrong_protocol_type;
+ using std::errc::wrong_protocol_type;
}
Index: testsuite/19_diagnostics/system_error/cons-1.cc
===================================================================
--- testsuite/19_diagnostics/system_error/cons-1.cc (revision 141102)
+++ testsuite/19_diagnostics/system_error/cons-1.cc (working copy)
@@ -27,7 +27,7 @@
{
bool test __attribute__((unused)) = true;
const std::string s("too late: boulangerie out of pain au raisin");
- const std::error_code e(std::posix_error::operation_not_supported);
+ const std::error_code e(std::errc::operation_not_supported);
// 1
{
Index: testsuite/19_diagnostics/system_error/what-4.cc
===================================================================
--- testsuite/19_diagnostics/system_error/what-4.cc (revision 141102)
+++ testsuite/19_diagnostics/system_error/what-4.cc (working copy)
@@ -32,7 +32,7 @@
bool test __attribute__((unused)) = true;
std::string s("after nine thirty, this request cannot be met");
- std::system_error obj = std::system_error(std::posix_error::invalid_argument, s);
+ std::system_error obj = std::system_error(std::errc::invalid_argument, s);
std::string s1(obj.what());
std::string s2(obj.what());
VERIFY( s1 == s2 );
Index: testsuite/30_threads/unique_lock/locking/2.cc
===================================================================
--- testsuite/30_threads/unique_lock/locking/2.cc (revision 141102)
+++ testsuite/30_threads/unique_lock/locking/2.cc (working copy)
@@ -54,7 +54,7 @@
catch (const std::system_error& ex)
{
VERIFY( ex.code() == std::error_code(
- std::posix_error::operation_not_permitted) );
+ std::errc::operation_not_permitted) );
}
catch (...)
{
@@ -91,7 +91,7 @@
catch (const std::system_error& ex)
{
VERIFY( ex.code() == std::error_code(
- std::posix_error::resource_deadlock_would_occur) );
+ std::errc::resource_deadlock_would_occur) );
}
catch (...)
{
Index: config/os/mingw32/error_constants.h
===================================================================
--- config/os/mingw32/error_constants.h (revision 141102)
+++ config/os/mingw32/error_constants.h (working copy)
@@ -41,10 +41,9 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
-namespace posix_error {
// Most of the commented-out error codes are socket-related and could be
// replaced by Winsock WSA-prefixed equivalents.
- enum posix_errno
+ enum class errc
{
// address_family_not_supported = EAFNOSUPPORT,
// address_in_use = EADDRINUSE,
@@ -126,7 +125,6 @@
// wrong_protocol_type = EPROTOTYPE,
no_posix_equivalent = 1L << 16
};
-}
_GLIBCXX_END_NAMESPACE
Index: config/os/generic/error_constants.h
===================================================================
--- config/os/generic/error_constants.h (revision 141102)
+++ config/os/generic/error_constants.h (working copy)
@@ -40,9 +40,7 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
-namespace posix_error
-{
- enum posix_errno
+ enum class errc
{
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
@@ -177,7 +175,6 @@
wrong_protocol_type = EPROTOTYPE,
no_posix_equivalent = 1L << 16
};
-}
_GLIBCXX_END_NAMESPACE
Index: config/abi/pre/gnu.ver
===================================================================
--- config/abi/pre/gnu.ver (revision 141102)
+++ config/abi/pre/gnu.ver (working copy)
@@ -922,7 +922,7 @@
_ZNSt6threadD2Ev;
# system_error
- _ZSt18get_posix_categoryv;
+ _ZSt20get_generic_categoryv;
_ZSt19get_system_categoryv;
_ZNKSt10error_code23default_error_conditionEv;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [v3] c++0x <system_error> CD updates
2008-10-14 15:09 [v3] c++0x <system_error> CD updates Chris Fairles
@ 2008-10-14 15:37 ` Paolo Carlini
2008-10-15 16:08 ` Chris Fairles
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Carlini @ 2008-10-14 15:37 UTC (permalink / raw)
To: Chris Fairles; +Cc: Gcc Patch List, libstdc++
Chris Fairles wrote:
> FAIL: ext/mt_allocator/deallocate_local_thread-5.cc execution test
> FAIL: ext/mt_allocator/deallocate_local_thread-7.cc execution test
>
I don't think these are directly related to your work. These tests are
weak and fail for some targets already (I think there are issues with
the stack size).
> Besides those, feel free to comment/review. I'll post an updated patch
> once I figure out those segfaults.
>
Ok...
Paolo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [v3] c++0x <system_error> CD updates
2008-10-14 15:37 ` Paolo Carlini
@ 2008-10-15 16:08 ` Chris Fairles
2008-10-15 16:40 ` Paolo Carlini
0 siblings, 1 reply; 8+ messages in thread
From: Chris Fairles @ 2008-10-15 16:08 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Gcc Patch List, libstdc++
[-- Attachment #1: Type: text/plain, Size: 357 bytes --]
Just to follow up on the seg fault. It happens because default
constructed error_code's, &system_category returns 0. So any
e.category().name() will seg fault since &e.category() == 0. Kind of
at a loss as to why. In a contained test case I can't reproduce it
(attached the appropriate files).
I have a feeling I'm missing something obvious here...
Chris
[-- Attachment #2: sys.hpp --]
[-- Type: text/plain, Size: 371 bytes --]
class error_category
{
protected:
error_category() = default;
public:
virtual const char*
name() const = 0;
};
const error_category&
get_category();
static const error_category& category = get_category();
class error_code
{
public:
error_code() : _c(&category) { }
const error_category& cat() const { return *_c; }
private:
const error_category* _c;
};
[-- Attachment #3: sys.cpp --]
[-- Type: text/plain, Size: 266 bytes --]
#include "sys.hpp"
namespace
{
class category_impl : public error_category
{
public:
virtual const char*
name() const
{ return "category"; }
};
const category_impl my_category;
}
const error_category&
get_category()
{ return my_category; }
[-- Attachment #4: system3.cpp --]
[-- Type: text/plain, Size: 129 bytes --]
#include "sys.hpp"
#include <iostream>
int main()
{
error_code e1;
std::cout << e1.cat().name() << std::endl;
return 0;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [v3] c++0x <system_error> CD updates
2008-10-15 16:08 ` Chris Fairles
@ 2008-10-15 16:40 ` Paolo Carlini
2008-10-15 16:49 ` Chris Fairles
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Carlini @ 2008-10-15 16:40 UTC (permalink / raw)
To: Chris Fairles; +Cc: Gcc Patch List, libstdc++
Chris Fairles wrote:
> I have a feeling I'm missing something obvious here...
>
I think this is one of those static initialization order issues, often
very annoying.
In fact, these:
static const error_category& system_category = get_system_category();
...
didn't really convince me, when I looked at the existing code: at
minimum, we are going to have one instance of system_category & co in
each translation unit. No good. Can't we export the statics from the
.so, as usual in such cases?
Paolo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [v3] c++0x <system_error> CD updates
2008-10-15 16:40 ` Paolo Carlini
@ 2008-10-15 16:49 ` Chris Fairles
2008-10-15 16:51 ` Paolo Carlini
0 siblings, 1 reply; 8+ messages in thread
From: Chris Fairles @ 2008-10-15 16:49 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Gcc Patch List, libstdc++
> Can't we export the statics from the .so, as usual in such cases?
Turns out there's a DR related to this (LWG, DR 890). The suggested
solution is to get rid of the get_* functions and leave the storage
specifier impl. defined. Its still "Open" but have a strong feeling
that it will be resolved somehow, if not with the current suggested
solution.
Going to give it a whirl.
Chris
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [v3] c++0x <system_error> CD updates
2008-10-15 16:49 ` Chris Fairles
@ 2008-10-15 16:51 ` Paolo Carlini
2008-10-22 14:23 ` Chris Fairles
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Carlini @ 2008-10-15 16:51 UTC (permalink / raw)
To: Chris Fairles; +Cc: Gcc Patch List, libstdc++
Chris Fairles wrote:
> Going to give it a whirl.
>
Agreed. Let's do something that makes sense, for now. I got a message
from Martin, and frankly I have no idea where are we going with this
issue, at the moment. Certainly the issue is real.
Paolo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [v3] c++0x <system_error> CD updates
2008-10-15 16:51 ` Paolo Carlini
@ 2008-10-22 14:23 ` Chris Fairles
2008-10-22 17:39 ` Paolo Carlini
0 siblings, 1 reply; 8+ messages in thread
From: Chris Fairles @ 2008-10-22 14:23 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Gcc Patch List, libstdc++
[-- Attachment #1: Type: text/plain, Size: 753 bytes --]
On Wed, Oct 15, 2008 at 12:07 PM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> Chris Fairles wrote:
>> Going to give it a whirl.
>>
> Agreed. Let's do something that makes sense, for now. I got a message
> from Martin, and frankly I have no idea where are we going with this
> issue, at the moment. Certainly the issue is real.
>
> Paolo.
>
Updated patch and changelog. Regtested x86_64 linux (with and without -Wall)
One thing I'm not clear on is why error_code's default ctor uses
system_category while error_condition uses generic_category. I think
if the integral value maps to an errc, then you use generic_category
and since 0 isn't, the error_code default ctor uses system_category
but I have no idea why error_condition's doesn't.
Chris
[-- Attachment #2: Changelog_system_error.txt --]
[-- Type: text/plain, Size: 3402 bytes --]
Index: ChangeLog
===================================================================
--- ChangeLog (revision 141290)
+++ ChangeLog (working copy)
@@ -1,3 +1,62 @@
+2008-10-21 Chris Fairles <cfairles@gcc.gnu.org>
+
+ * include/std/system_error (is_error_code_enum): Specialize for errc.
+ (error_category::error_category): Defaulted and protected.
+ (error_category::~error_category): New, virtual.
+ (error_category::error_category(const error_category&),
+ error_category::operator=(const error_category&)): Deleted.
+ (get_system_category, get_posix_category): Remove (DR 890).
+ (system_category): External linkage (DR 890).
+ (posix_category): Remove.
+ (generic_category): Add. External linkage (DR 890).
+ (error_code::error_code<>(_ErrorCodeEnum)): Use generic_category.
+ (error_code::clear, error_code::operator=<>(_ErrorCodeEnum)): Forward to
+ error_code::assign, use generic_category.
+ (error_condition::error_condition,
+ error_condition::error_condition<>(_ErrorConditionEnum)): Use
+ generic_category.
+ (error_condition::clear,
+ error_condition::operator=<>(_ErrorConditionEnum)): Forward to
+ error_code::assign, use generic_category.
+ (make_error_code, make_error_condition): Define in namespace std.
+ * include/std/mutex (unique_lock<>::lock, unique_lock<>::try_lock,
+ unique_lock<>::try_lock_until<>(duration),
+ unique_lock<>::try_lock_for<>(duration)): Replace posix_error with errc.
+ * src/system_error.cc (system_error_category, generic_error_category):
+ New.
+ (gnu_error_category): Remove.
+ (get_system_category, get_posix_category): Remove (DR 890).
+ (system_category, generic_category): Define.
+ * src/functexcept.cc (__throw_system_error): Use generic_category.
+ * config/abi/pre/gnu.ver: Export system_category and generic_category,
+ remove get_system_category and get_generic_category (DR 890).
+ * config/os/generic/error_constants.h (posix_errno): Rename to errc, use
+ enum class type. Fix spelling.
+ * config/os/mingw32/error_constants.h (posix_errno): Likewise.
+ * testsuite/19_diagnostics/error_code/cons/1.cc: Use errc and
+ generic_category.
+ * testsuite/19_diagnostics/error_code/operators/bool.cc: Use errc.
+ * testsuite/19_diagnostics/error_code/operators/equal.cc: Likewise.
+ * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Likewise.
+ * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Update
+ dg-error line numbers.
+ * testsuite/19_diagnostics/error_condition/cons/1.cc: Use
+ generic_category.
+ * testsuite/19_diagnostics/error_condition/operators/bool.cc: Use errc.
+ * testsuite/19_diagnostics/error_condition/operators/equal.cc: Likewise.
+ * testsuite/19_diagnostics/error_condition/operators/not_equal.cc:
+ Likewise.
+ * testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: New.
+ * testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc:
+ Remove using tests since errc is not a namespace.
+ * testsuite/19_diagnostics/system_error/cons-1.cc: Use errc.
+ * testsuite/19_diagnostics/system_error/what-4.cc: Likewise.
+ * testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc:
+ Likewise.
+ * testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc:
+ Likewise.
+ * testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
+
2008-10-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/tr1_impl/hashtable_policy.h (_Hash_node<>::_Hash_node<>
[-- Attachment #3: system_error.patch.txt --]
[-- Type: text/plain, Size: 29734 bytes --]
Index: src/functexcept.cc
===================================================================
--- src/functexcept.cc (revision 141290)
+++ src/functexcept.cc (working copy)
@@ -102,7 +102,7 @@
void
__throw_system_error(int __i)
- { throw system_error(error_code(__i, system_category)); }
+ { throw system_error(error_code(__i, generic_category)); }
void
__throw_ios_failure(const char* __s)
Index: src/system_error.cc
===================================================================
--- src/system_error.cc (revision 141290)
+++ src/system_error.cc (working copy)
@@ -36,15 +36,12 @@
namespace
{
using std::string;
-
- struct gnu_error_category : public std::error_category
+
+ struct generic_error_category : public std::error_category
{
virtual const char*
name() const
- {
- const char* s = "GNU";
- return s;
- }
+ { return "generic"; }
virtual string
message(int i) const
@@ -55,17 +52,30 @@
}
};
- const gnu_error_category gnu_category;
+ struct system_error_category : public std::error_category
+ {
+ virtual const char*
+ name() const
+ { return "system"; }
+
+ virtual string
+ message(int i) const
+ {
+ // XXX locale issues: how does one get or set loc.
+ // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc)
+ return string(strerror(i));
+ }
+ };
+
+ const generic_error_category generic_category_instance;
+ const system_error_category system_category_instance;
}
_GLIBCXX_BEGIN_NAMESPACE(std)
- const error_category&
- get_posix_category() { return gnu_category; }
-
- const error_category&
- get_system_category() { return gnu_category; }
-
+ const error_category& system_category = system_category_instance;
+ const error_category& generic_category = generic_category_instance;
+
system_error::~system_error() throw() { }
error_condition
Index: include/std/system_error
===================================================================
--- include/std/system_error (revision 141290)
+++ include/std/system_error (working copy)
@@ -57,7 +57,7 @@
struct is_error_code_enum : public false_type { };
template<>
- struct is_error_code_enum<posix_error::posix_errno>
+ struct is_error_code_enum<errc>
: public true_type { };
/// is_error_condition_enum
@@ -65,15 +65,22 @@
struct is_error_condition_enum : public false_type { };
template<>
- struct is_error_condition_enum<posix_error::posix_errno>
+ struct is_error_condition_enum<errc>
: public true_type { };
/// error_category
- struct error_category
+ class error_category
{
- error_category() { }
+ protected:
+ error_category() = default;
+ public:
+ virtual ~error_category() { }
+
+ error_category(const error_category&) = delete;
+ error_category& operator=(const error_category&) = delete;
+
virtual const char*
name() const = 0;
@@ -100,20 +107,12 @@
bool
operator!=(const error_category& __other) const
{ return this != &__other; }
-
- private:
- error_category(const error_category&);
-
- error_category&
- operator=(const error_category&);
};
- const error_category& get_posix_category();
- const error_category& get_system_category();
+ // DR 890.
+ extern const error_category& system_category;
+ extern const error_category& generic_category;
- static const error_category& posix_category = get_posix_category();
- static const error_category& system_category = get_system_category();
-
/// error_code
// Implementation-specific error identification
struct error_code
@@ -127,7 +126,7 @@
template<typename _ErrorCodeEnum>
error_code(_ErrorCodeEnum __e,
typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0)
- : _M_value(__e), _M_cat(&posix_category)
+ : _M_value(static_cast<int>(__e)), _M_cat(&generic_category)
{ }
void
@@ -139,10 +138,7 @@
void
clear()
- {
- _M_value = 0;
- _M_cat = &system_category;
- }
+ { assign(0, system_category); }
// DR 804.
template<typename _ErrorCodeEnum>
@@ -150,8 +146,7 @@
error_code&>::type
operator=(_ErrorCodeEnum __e)
{
- _M_value = __e;
- _M_cat = &posix_category;
+ assign(static_cast<int>(__e), generic_category);
return *this;
}
@@ -184,7 +179,11 @@
const error_category* _M_cat;
};
- // 19.4.2.5 non-member functions
+ // 19.4.2.6 non-member functions
+ inline error_code
+ make_error_code(errc __e)
+ { return error_code(static_cast<int>(__e), generic_category); }
+
inline bool
operator<(const error_code& __lhs, const error_code& __rhs)
{
@@ -203,7 +202,7 @@
// Portable error identification
struct error_condition
{
- error_condition() : _M_value(0), _M_cat(&posix_category) { }
+ error_condition() : _M_value(0), _M_cat(&generic_category) { }
error_condition(int __v, const error_category& __cat)
: _M_value(__v), _M_cat(&__cat) { }
@@ -212,7 +211,7 @@
error_condition(_ErrorConditionEnum __e,
typename enable_if<is_error_condition_enum
<_ErrorConditionEnum>::value>::type* = 0)
- : _M_value(__e), _M_cat(&posix_category) { }
+ : _M_value(static_cast<int>(__e)), _M_cat(&generic_category) { }
void
assign(int __v, const error_category& __cat)
@@ -227,17 +226,13 @@
<_ErrorConditionEnum>::value, error_condition&>::type
operator=(_ErrorConditionEnum __e)
{
- _M_value = __e;
- _M_cat = &posix_category;
+ assign(static_cast<int>(__e), generic_category);
return *this;
}
void
clear()
- {
- _M_value = 0;
- _M_cat = &posix_category;
- }
+ { assign(0, generic_category); }
// 19.4.3.4 observers
int
@@ -266,7 +261,11 @@
const error_category* _M_cat;
};
- // 19.4.3.5 non-member functions
+ // 19.4.3.6 non-member functions
+ inline error_condition
+ make_error_condition(errc __e)
+ { return error_condition(static_cast<int>(__e), generic_category); }
+
inline bool
operator<(const error_condition& __lhs, const error_condition& __rhs)
{
@@ -275,17 +274,6 @@
&& __lhs.value() < __rhs.value()));
}
- namespace posix_error
- {
- inline error_code
- make_error_code(posix_errno __e)
- { return error_code(__e, posix_category); }
-
- inline error_condition
- make_error_condition(posix_errno __e)
- { return error_condition(__e, posix_category); }
- }
-
// 19.4.4 Comparison operators
inline bool
operator==(const error_code& __lhs, const error_code& __rhs)
@@ -342,6 +330,16 @@
system_error(error_code __ec, const string& __what)
: runtime_error(__what), _M_code(__ec) { }
+
+ /*
+ * TODO: Add const char* ctors to all exceptions.
+ *
+ * system_error(error_code __ec, const char* __what)
+ * : runtime_error(__what), _M_code(__ec) { }
+ *
+ * system_error(int __v, const error_category& __ecat, const char* __what)
+ * : runtime_error(__what), _M_code(error_code(__v, __ecat)) { }
+ */
system_error(int __v, const error_category& __ecat)
: runtime_error(""), _M_code(error_code(__v, __ecat)) { }
Index: include/std/mutex
===================================================================
--- include/std/mutex (revision 141290)
+++ include/std/mutex (working copy)
@@ -489,9 +489,9 @@
lock()
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_device->lock();
@@ -503,9 +503,9 @@
try_lock()
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_owns = _M_device->try_lock();
@@ -518,9 +518,9 @@
try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_owns = _M_device->try_lock_until(__atime);
@@ -533,9 +533,9 @@
try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
{
if (!_M_device)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_owns)
- __throw_system_error(posix_error::resource_deadlock_would_occur);
+ __throw_system_error((int)errc::resource_deadlock_would_occur);
else
{
_M_owns = _M_device->try_lock_for(__rtime);
@@ -547,7 +547,7 @@
unlock()
{
if (!_M_owns)
- __throw_system_error(posix_error::operation_not_permitted);
+ __throw_system_error((int)errc::operation_not_permitted);
else if (_M_device)
{
_M_device->unlock();
Index: testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
===================================================================
--- testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc (revision 141290)
+++ testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc (working copy)
@@ -33,7 +33,7 @@
wchar_t buf[64];
error_code e1;
- error_code e2(posix_error::bad_address);
+ error_code e2(errc::bad_address);
wstring s, s1, s2;
{
Index: testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc
===================================================================
--- testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc (revision 141290)
+++ testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc (working copy)
@@ -33,7 +33,7 @@
char buf[64];
error_code e1;
- error_code e2(posix_error::bad_address);
+ error_code e2(errc::bad_address);
string s, s1, s2;
{
Index: testsuite/19_diagnostics/error_condition/cons/1.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/cons/1.cc (revision 141290)
+++ testsuite/19_diagnostics/error_condition/cons/1.cc (working copy)
@@ -28,7 +28,7 @@
// 1
std::error_condition e1;
VERIFY( e1.value() == 0 );
- VERIFY( e1.category() == std::posix_category );
+ VERIFY( e1.category() == std::generic_category );
// 2
const __gnu_test::test_category cat;
@@ -37,9 +37,9 @@
VERIFY( e2.category() == cat );
// 3
- std::error_condition e3(std::posix_error::operation_not_supported);
- VERIFY( e3.value() == int(std::posix_error::operation_not_supported) );
- VERIFY( e3.category() == std::posix_category );
+ std::error_condition e3(std::errc::operation_not_supported);
+ VERIFY( e3.value() == int(std::errc::operation_not_supported) );
+ VERIFY( e3.category() == std::generic_category );
}
int main()
Index: testsuite/19_diagnostics/error_condition/operators/bool.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/operators/bool.cc (revision 141290)
+++ testsuite/19_diagnostics/error_condition/operators/bool.cc (working copy)
@@ -34,7 +34,7 @@
}
// 2
- std::error_condition e2(std::posix_error::operation_not_supported);
+ std::error_condition e2(std::errc::operation_not_supported);
if (e2)
{
VERIFY( true );
Index: testsuite/19_diagnostics/error_condition/operators/equal.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/operators/equal.cc (revision 141290)
+++ testsuite/19_diagnostics/error_condition/operators/equal.cc (working copy)
@@ -27,7 +27,7 @@
bool test __attribute__((unused)) = true;
std::error_condition e1;
- std::error_condition e2(std::posix_error::operation_not_supported);
+ std::error_condition e2(std::errc::operation_not_supported);
VERIFY( e1 == e1 );
VERIFY( !(e1 == e2) );
Index: testsuite/19_diagnostics/error_condition/operators/not_equal.cc
===================================================================
--- testsuite/19_diagnostics/error_condition/operators/not_equal.cc (revision 141290)
+++ testsuite/19_diagnostics/error_condition/operators/not_equal.cc (working copy)
@@ -27,7 +27,7 @@
bool test __attribute__((unused)) = true;
std::error_condition e1;
- std::error_condition e2(std::posix_error::operation_not_supported);
+ std::error_condition e2(std::errc::operation_not_supported);
VERIFY( !(e1 != e1) );
VERIFY( e1 != e2 );
Index: testsuite/19_diagnostics/error_code/cons/1.cc
===================================================================
--- testsuite/19_diagnostics/error_code/cons/1.cc (revision 141290)
+++ testsuite/19_diagnostics/error_code/cons/1.cc (working copy)
@@ -38,9 +38,9 @@
VERIFY( e2.category() == cat );
// 3
- std::error_code e3(std::posix_error::operation_not_supported);
- VERIFY( e3.value() == int(std::posix_error::operation_not_supported) );
- VERIFY( e3.category() == std::posix_category );
+ std::error_code e3(std::errc::operation_not_supported);
+ VERIFY( e3.value() == int(std::errc::operation_not_supported) );
+ VERIFY( e3.category() == std::generic_category );
return 0;
}
Index: testsuite/19_diagnostics/error_code/operators/bool.cc
===================================================================
--- testsuite/19_diagnostics/error_code/operators/bool.cc (revision 141290)
+++ testsuite/19_diagnostics/error_code/operators/bool.cc (working copy)
@@ -35,7 +35,7 @@
}
// 2
- std::error_code e2(std::posix_error::operation_not_supported);
+ std::error_code e2(std::errc::operation_not_supported);
if (e2)
{
VERIFY( true );
Index: testsuite/19_diagnostics/error_code/operators/equal.cc
===================================================================
--- testsuite/19_diagnostics/error_code/operators/equal.cc (revision 141290)
+++ testsuite/19_diagnostics/error_code/operators/equal.cc (working copy)
@@ -28,7 +28,7 @@
bool test __attribute__((unused)) = true;
std::error_code e1;
- std::error_code e2(std::posix_error::operation_not_supported);
+ std::error_code e2(std::errc::operation_not_supported);
VERIFY( e1 == e1 );
VERIFY( !(e1 == e2) );
Index: testsuite/19_diagnostics/error_code/operators/not_equal.cc
===================================================================
--- testsuite/19_diagnostics/error_code/operators/not_equal.cc (revision 141290)
+++ testsuite/19_diagnostics/error_code/operators/not_equal.cc (working copy)
@@ -28,7 +28,7 @@
bool test __attribute__((unused)) = true;
std::error_code e1;
- std::error_code e2(std::posix_error::operation_not_supported);
+ std::error_code e2(std::errc::operation_not_supported);
VERIFY( !(e1 != e1) );
VERIFY( e1 != e2 );
Index: testsuite/19_diagnostics/error_category/cons/copy_neg.cc
===================================================================
--- testsuite/19_diagnostics/error_category/cons/copy_neg.cc (revision 141290)
+++ testsuite/19_diagnostics/error_category/cons/copy_neg.cc (working copy)
@@ -33,7 +33,7 @@
return 0;
}
-// { dg-error "is private" "" { target *-*-* } 105 }
-// { dg-error "within this context" "" { target *-*-* } 40 }
+// { dg-error "deleted function" "" { target *-*-* } 81 }
+// { dg-error "used here" "" { target *-*-* } 40 }
// { dg-error "first required here" "" { target *-*-* } 31 }
// { dg-excess-errors "copy constructor" }
Index: testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc
===================================================================
--- testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc (revision 141290)
+++ testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc (working copy)
@@ -27,135 +27,4 @@
using std::error_code;
using std::error_category;
using std::system_category;
-
- using std::posix_error::posix_errno;
- using std::posix_error::address_family_not_supported;
- using std::posix_error::address_in_use;
- using std::posix_error::address_not_available;
- using std::posix_error::already_connected;
- using std::posix_error::argument_list_too_long;
- using std::posix_error::argument_out_of_domain;
- using std::posix_error::bad_address;
- using std::posix_error::bad_file_descriptor;
-
-#ifdef _GLIBCXX_HAVE_EBADMSG
- using std::posix_error::bad_message;
-#endif
-
- using std::posix_error::broken_pipe;
- using std::posix_error::connection_aborted;
- using std::posix_error::connection_already_in_progress;
- using std::posix_error::connection_refused;
- using std::posix_error::connection_reset;
- using std::posix_error::cross_device_link;
- using std::posix_error::destination_address_required;
- using std::posix_error::device_or_resource_busy;
- using std::posix_error::directory_not_empty;
- using std::posix_error::executable_format_error;
- using std::posix_error::file_exists;
- using std::posix_error::file_too_large;
- using std::posix_error::filename_too_long;
- using std::posix_error::function_not_supported;
- using std::posix_error::host_unreachable;
-
-#ifdef _GLIBCXX_HAVE_EIDRM
- using std::posix_error::identifier_removed;
-#endif
-
- using std::posix_error::illegal_byte_sequence;
- using std::posix_error::inappropriate_io_control_operation;
- using std::posix_error::interrupted;
- using std::posix_error::invalid_argument;
- using std::posix_error::invalid_seek;
- using std::posix_error::io_error;
- using std::posix_error::is_a_directory;
- using std::posix_error::message_size;
- using std::posix_error::network_down;
- using std::posix_error::network_reset;
- using std::posix_error::network_unreachable;
- using std::posix_error::no_buffer_space;
- using std::posix_error::no_child_process;
-
-#ifdef _GLIBCXX_HAVE_ENOLINK
- using std::posix_error::no_link;
-#endif
-
- using std::posix_error::no_lock_available;
-
-#ifdef _GLIBCXX_HAVE_ENODATA
- using std::posix_error::no_message_available;
-#endif
-
- using std::posix_error::no_message;
- using std::posix_error::no_posix_equivalent;
- using std::posix_error::no_protocol_option;
- using std::posix_error::no_space_on_device;
-
-#ifdef _GLIBCXX_HAVE_ENOSR
- using std::posix_error::no_stream_resources;
-#endif
-
- using std::posix_error::no_such_device_or_address;
- using std::posix_error::no_such_device;
- using std::posix_error::no_such_file_or_directory;
- using std::posix_error::no_such_process;
- using std::posix_error::not_a_directory;
- using std::posix_error::not_a_socket;
-
-#ifdef _GLIBCXX_HAVE_ENOSTR
- using std::posix_error::not_a_stream;
-#endif
-
- using std::posix_error::not_connected;
- using std::posix_error::not_enough_memory;
- using std::posix_error::not_supported;
-
-#ifdef _GLIBCXX_HAVE_ECANCELED
- using std::posix_error::operation_canceled;
-#endif
-
- using std::posix_error::operation_in_progress;
- using std::posix_error::operation_not_permitted;
- using std::posix_error::operation_not_supported;
- using std::posix_error::operation_would_block;
-
-#ifdef _GLIBCXX_HAVE_EOWNERDEAD
- using std::posix_error::owner_dead;
-#endif
-
- using std::posix_error::permission_denied;
-
-#ifdef _GLIBCXX_HAVE_EPROTO
- using std::posix_error::protocol_error;
-#endif
-
- using std::posix_error::protocol_not_supported;
- using std::posix_error::read_only_file_system;
- using std::posix_error::resource_deadlock_would_occur;
- using std::posix_error::resource_unavailable_try_again;
- using std::posix_error::result_out_of_range;
-
-#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
- using std::posix_error::state_not_recoverable;
-#endif
-
-#ifdef _GLIBCXX_HAVE_ETIME
- using std::posix_error::stream_timeout;
-#endif
-
-#ifdef _GLIBCXX_HAVE_ETXTBSY
- using std::posix_error::text_file_busy;
-#endif
-
- using std::posix_error::timed_out;
- using std::posix_error::too_many_files_open_in_system;
- using std::posix_error::too_many_files_open;
- using std::posix_error::too_many_links;
- using std::posix_error::too_many_synbolic_link_levels;
-
-#ifdef _GLIBCXX_HAVE_EOVERFLOW
- using std::posix_error::value_too_large;
-#endif
-
- using std::posix_error::wrong_protocol_type;
}
Index: testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
===================================================================
--- testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc (revision 0)
+++ testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc (revision 0)
@@ -0,0 +1,159 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <system_error>
+
+#define TEST_ERRC(x) errc x(errc::x); (void)x
+
+void test01()
+{
+ using std::errc;
+
+ TEST_ERRC(address_family_not_supported);
+ TEST_ERRC(address_in_use);
+ TEST_ERRC(address_not_available);
+ TEST_ERRC(already_connected);
+ TEST_ERRC(argument_list_too_long);
+ TEST_ERRC(argument_out_of_domain);
+ TEST_ERRC(bad_address);
+ TEST_ERRC(bad_file_descriptor);
+
+#ifdef _GLIBCXX_HAVE_EBADMSG
+ TEST_ERRC(bad_message);
+#endif
+
+ TEST_ERRC(broken_pipe);
+ TEST_ERRC(connection_aborted);
+ TEST_ERRC(connection_already_in_progress);
+ TEST_ERRC(connection_refused);
+ TEST_ERRC(connection_reset);
+ TEST_ERRC(cross_device_link);
+ TEST_ERRC(destination_address_required);
+ TEST_ERRC(device_or_resource_busy);
+ TEST_ERRC(directory_not_empty);
+ TEST_ERRC(executable_format_error);
+ TEST_ERRC(file_exists);
+ TEST_ERRC(file_too_large);
+ TEST_ERRC(filename_too_long);
+ TEST_ERRC(function_not_supported);
+ TEST_ERRC(host_unreachable);
+
+#ifdef _GLIBCXX_HAVE_EIDRM
+ TEST_ERRC(identifier_removed);
+#endif
+
+ TEST_ERRC(illegal_byte_sequence);
+ TEST_ERRC(inappropriate_io_control_operation);
+ TEST_ERRC(interrupted);
+ TEST_ERRC(invalid_argument);
+ TEST_ERRC(invalid_seek);
+ TEST_ERRC(io_error);
+ TEST_ERRC(is_a_directory);
+ TEST_ERRC(message_size);
+ TEST_ERRC(network_down);
+ TEST_ERRC(network_reset);
+ TEST_ERRC(network_unreachable);
+ TEST_ERRC(no_buffer_space);
+ TEST_ERRC(no_child_process);
+
+#ifdef _GLIBCXX_HAVE_ENOLINK
+ TEST_ERRC(no_link);
+#endif
+
+ TEST_ERRC(no_lock_available);
+
+#ifdef _GLIBCXX_HAVE_ENODATA
+ TEST_ERRC(no_message_available);
+#endif
+
+ TEST_ERRC(no_message);
+ TEST_ERRC(no_posix_equivalent);
+ TEST_ERRC(no_protocol_option);
+ TEST_ERRC(no_space_on_device);
+
+#ifdef _GLIBCXX_HAVE_ENOSR
+ TEST_ERRC(no_stream_resources);
+#endif
+
+ TEST_ERRC(no_such_device_or_address);
+ TEST_ERRC(no_such_device);
+ TEST_ERRC(no_such_file_or_directory);
+ TEST_ERRC(no_such_process);
+ TEST_ERRC(not_a_directory);
+ TEST_ERRC(not_a_socket);
+
+#ifdef _GLIBCXX_HAVE_ENOSTR
+ TEST_ERRC(not_a_stream);
+#endif
+
+ TEST_ERRC(not_connected);
+ TEST_ERRC(not_enough_memory);
+ TEST_ERRC(not_supported);
+
+#ifdef _GLIBCXX_HAVE_ECANCELED
+ TEST_ERRC(operation_canceled);
+#endif
+
+ TEST_ERRC(operation_in_progress);
+ TEST_ERRC(operation_not_permitted);
+ TEST_ERRC(operation_not_supported);
+ TEST_ERRC(operation_would_block);
+
+#ifdef _GLIBCXX_HAVE_EOWNERDEAD
+ TEST_ERRC(owner_dead);
+#endif
+
+ TEST_ERRC(permission_denied);
+
+#ifdef _GLIBCXX_HAVE_EPROTO
+ TEST_ERRC(protocol_error);
+#endif
+
+ TEST_ERRC(protocol_not_supported);
+ TEST_ERRC(read_only_file_system);
+ TEST_ERRC(resource_deadlock_would_occur);
+ TEST_ERRC(resource_unavailable_try_again);
+ TEST_ERRC(result_out_of_range);
+
+#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
+ TEST_ERRC(state_not_recoverable);
+#endif
+
+#ifdef _GLIBCXX_HAVE_ETIME
+ TEST_ERRC(stream_timeout);
+#endif
+
+#ifdef _GLIBCXX_HAVE_ETXTBSY
+ TEST_ERRC(text_file_busy);
+#endif
+
+ TEST_ERRC(timed_out);
+ TEST_ERRC(too_many_files_open_in_system);
+ TEST_ERRC(too_many_files_open);
+ TEST_ERRC(too_many_links);
+ TEST_ERRC(too_many_symbolic_link_levels);
+
+#ifdef _GLIBCXX_HAVE_EOVERFLOW
+ TEST_ERRC(value_too_large);
+#endif
+
+ TEST_ERRC(wrong_protocol_type);
+}
Index: testsuite/19_diagnostics/system_error/cons-1.cc
===================================================================
--- testsuite/19_diagnostics/system_error/cons-1.cc (revision 141290)
+++ testsuite/19_diagnostics/system_error/cons-1.cc (working copy)
@@ -27,7 +27,7 @@
{
bool test __attribute__((unused)) = true;
const std::string s("too late: boulangerie out of pain au raisin");
- const std::error_code e(std::posix_error::operation_not_supported);
+ const std::error_code e(std::errc::operation_not_supported);
// 1
{
Index: testsuite/19_diagnostics/system_error/what-4.cc
===================================================================
--- testsuite/19_diagnostics/system_error/what-4.cc (revision 141290)
+++ testsuite/19_diagnostics/system_error/what-4.cc (working copy)
@@ -32,7 +32,7 @@
bool test __attribute__((unused)) = true;
std::string s("after nine thirty, this request cannot be met");
- std::system_error obj = std::system_error(std::posix_error::invalid_argument, s);
+ std::system_error obj = std::system_error(std::errc::invalid_argument, s);
std::string s1(obj.what());
std::string s2(obj.what());
VERIFY( s1 == s2 );
Index: testsuite/30_threads/unique_lock/locking/2.cc
===================================================================
--- testsuite/30_threads/unique_lock/locking/2.cc (revision 141290)
+++ testsuite/30_threads/unique_lock/locking/2.cc (working copy)
@@ -53,8 +53,7 @@
}
catch (const std::system_error& ex)
{
- VERIFY( ex.code() == std::error_code(
- std::posix_error::operation_not_permitted) );
+ VERIFY( ex.code() == std::error_code(std::errc::operation_not_permitted) );
}
catch (...)
{
@@ -91,7 +90,7 @@
catch (const std::system_error& ex)
{
VERIFY( ex.code() == std::error_code(
- std::posix_error::resource_deadlock_would_occur) );
+ std::errc::resource_deadlock_would_occur) );
}
catch (...)
{
Index: config/os/mingw32/error_constants.h
===================================================================
--- config/os/mingw32/error_constants.h (revision 141290)
+++ config/os/mingw32/error_constants.h (working copy)
@@ -41,10 +41,9 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
-namespace posix_error {
// Most of the commented-out error codes are socket-related and could be
// replaced by Winsock WSA-prefixed equivalents.
- enum posix_errno
+ enum class errc
{
// address_family_not_supported = EAFNOSUPPORT,
// address_in_use = EADDRINUSE,
@@ -121,12 +120,11 @@
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
- // too_many_synbolic_link_levels = ELOOP,
+ // too_many_symbolic_link_levels = ELOOP,
// value_too_large = EOVERFLOW,
// wrong_protocol_type = EPROTOTYPE,
no_posix_equivalent = 1L << 16
};
-}
_GLIBCXX_END_NAMESPACE
Index: config/os/generic/error_constants.h
===================================================================
--- config/os/generic/error_constants.h (revision 141290)
+++ config/os/generic/error_constants.h (working copy)
@@ -40,9 +40,7 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
-namespace posix_error
-{
- enum posix_errno
+ enum class errc
{
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
@@ -168,7 +166,7 @@
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
- too_many_synbolic_link_levels = ELOOP,
+ too_many_symbolic_link_levels = ELOOP,
#ifdef _GLIBCXX_HAVE_EOVERFLOW
value_too_large = EOVERFLOW,
@@ -177,7 +175,6 @@
wrong_protocol_type = EPROTOTYPE,
no_posix_equivalent = 1L << 16
};
-}
_GLIBCXX_END_NAMESPACE
Index: config/abi/pre/gnu.ver
===================================================================
--- config/abi/pre/gnu.ver (revision 141290)
+++ config/abi/pre/gnu.ver (working copy)
@@ -922,8 +922,8 @@
_ZNSt6threadD2Ev;
# system_error
- _ZSt18get_posix_categoryv;
- _ZSt19get_system_categoryv;
+ _ZSt15system_category;
+ _ZSt16generic_category;
_ZNKSt10error_code23default_error_conditionEv;
_ZNKSt14error_category23default_error_conditionEi;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [v3] c++0x <system_error> CD updates
2008-10-22 14:23 ` Chris Fairles
@ 2008-10-22 17:39 ` Paolo Carlini
0 siblings, 0 replies; 8+ messages in thread
From: Paolo Carlini @ 2008-10-22 17:39 UTC (permalink / raw)
To: Chris Fairles; +Cc: Gcc Patch List, libstdc++
Hi,
> Updated patch and changelog. Regtested x86_64 linux (with and without -Wall)
>
Patch is Ok, thanks. Note, we are exporting two symbols, system_category
and generic_category, which depend on the resolution of DR 890, and, in
principle, we will not be able tor "unexport" until the next
ABI-breakage (even if for C++0x features the rules are more lax...
Actually, C++0x exports should be probably in a class apart, we briefly
discussed that with Benjamin already). Thus, let's make sure to review
the issue when the release of gcc4.4.0 approaches.
> One thing I'm not clear on is why error_code's default ctor uses
> system_category while error_condition uses generic_category. I think
> if the integral value maps to an errc, then you use generic_category
> and since 0 isn't, the error_code default ctor uses system_category
> but I have no idea why error_condition's doesn't.
>
Yes, I was also slightly surprised by that (well the counterpart in the
previous WD). You may want to ask on the library reflector...
Thanks again,
Paolo.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-10-22 15:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-14 15:09 [v3] c++0x <system_error> CD updates Chris Fairles
2008-10-14 15:37 ` Paolo Carlini
2008-10-15 16:08 ` Chris Fairles
2008-10-15 16:40 ` Paolo Carlini
2008-10-15 16:49 ` Chris Fairles
2008-10-15 16:51 ` Paolo Carlini
2008-10-22 14:23 ` Chris Fairles
2008-10-22 17:39 ` Paolo Carlini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).