<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 697: New &lt;system_error&gt; header leads to name clashes</title>
<meta property="og:title" content="Issue 697: New &lt;system_error&gt; header leads to name clashes">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue697.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#Resolved">Resolved</a> status.</em></p>
<h3 id="697"><a href="lwg-defects.html#697">697</a>. New <code>&lt;system_error&gt;</code> header leads to name clashes</h3>
<p><b>Section:</b> 19.5 <a href="https://wg21.link/syserr">[syserr]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2007-06-24 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#syserr">issues</a> in [syserr].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The most recent state of 
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2241.html">N2241</a>
as well as the current draft
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2284.pdf">N2284</a>
(section 19.5 <a href="https://wg21.link/syserr">[syserr]</a>, p.2) proposes a
new
enumeration type <code>posix_errno</code> immediatly in the namespace <code>std</code>. One of
the enumerators has the name <code>invalid_argument</code>, or fully qualified:
<code>std::invalid_argument</code>. This name clashes with the exception type
<code>std::invalid_argument</code>, see 19.2 <a href="https://wg21.link/std.exceptions">[std.exceptions]</a>/p.3. This clash makes
e.g. the following snippet invalid:
</p>

<blockquote><pre>
#include &lt;system_error&gt;
#include &lt;stdexcept&gt;

void foo() { throw std::invalid_argument("Don't call us - we call you!"); }
</pre></blockquote>

<p>
I propose that this enumeration type (and probably the remaining parts
of
<code>&lt;system_error&gt;</code> as well) should be moved into one additional inner
namespace, e.g. <code>sys</code> or <code>system</code> to reduce foreseeable future clashes
due
to the great number of members that <code>std::posix_errno</code> already contains
(Btw.: Why has the already proposed <code>std::sys</code> sub-namespace from
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2066.html">N2066</a>
been rejected?). A further clash <em>candidate</em> seems to be
<code>std::protocol_error</code>
(a reasonable name for an exception related to a std network library,
I guess).
</p>

<p>
Another possible resolution would rely on the proposed strongly typed
enums,
as described in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2213.pdf">N2213</a>.
But maybe the forbidden implicit conversion to integral types would
make
these enumerators less attractive in this special case?
</p>


<p id="res-697"><b>Proposed resolution:</b></p>
<p>
Fixed by <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2422.htm#Issue7">issue 7 of N2422</a>.
</p>






</body>
</html>
