* [PATCH] wwwdocs: Add ADL to C++ non-bugs
@ 2023-10-03 14:45 Jonathan Wakely
2023-10-04 19:17 ` Jason Merrill
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2023-10-03 14:45 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
We have a long history of INVALID bugs about std functions being
available in the global namespace (PRs 27846, 67566, 82619, 99865,
110602, 111553, probably others). Let's document it.
Also de-prioritize the C++98-only bugs, which are unlikely to affect
anybody nowadays.
OK for wwwdocs?
-- >8 --
Add ADL to C++ non-bugs
Also move the item about C++98 'export' to the end, and update the item
about <: digraphs that only applies to C++98.
---
htdocs/bugs/index.html | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/htdocs/bugs/index.html b/htdocs/bugs/index.html
index 813b78c0..41edc561 100644
--- a/htdocs/bugs/index.html
+++ b/htdocs/bugs/index.html
@@ -539,15 +539,15 @@ for details.
<h2 id="nonbugs_cxx">C++</h2>
<dl>
-<dt><code>export</code></dt>
-<dd><p>Most C++ compilers (G++ included) never implemented C++98
-<code>export</code>, which was removed in C++11, and the keyword reused in
-C++20 by the Modules feature. The C++98 feature was intended to support
-separate compilation of template declarations and
-definitions. Without <code>export</code>, a template definition must be in
-scope to be used. The obvious workaround is simply to place all definitions in
-the header itself. Alternatively, the compilation unit containing template
-definitions may be included from the header.</p></dd>
+<dt>Functions can be called without qualifying them with their namespace.</dt>
+<dd>
+Argument Dependent Lookup (ADL) means that functions can be found in namespaces
+associated with their arguments. This means that <code>move(arg)</code> can
+call <code>std::move</code> if <code>arg</code> is a type defined in namespace
+<code>std</code>, such as <code>std::string</code> or <code>std::vector</code>.
+If <code>std::move</code> is not the function you intended to call, use a
+qualified name such as <code>::move(arg)</code> or <code>foo::move(arg)</code>.
+</dd>
<dt>Nested classes can access private members and types of the containing
class.</dt>
@@ -597,9 +597,9 @@ handler and catch it in the main thread.</p></dd>
<dd><p>If you have a class in the global namespace, say named <code>X</code>,
and want to give it as a template argument to some other class, say
<code>std::vector</code>, then <code>std::vector<::X></code>
-fails with a parser error.</p>
+fails with a parser error in C++98/C++03 mode.</p>
-<p>The reason is that the standard mandates that the sequence
+<p>The reason is that the C++98 standard mandates that the sequence
<code><:</code> is treated as if it were the token <code>[</code>.
(There are several such combinations of characters - they are called
<em>digraphs</em>.) Depending on the version, the compiler then reports
@@ -608,7 +608,19 @@ a parse error before the character <code>:</code> (the colon before
<p>The simplest way to avoid this is to write <code>std::vector<
::X></code>, i.e. place a space between the opening angle bracket
-and the scope operator.</p></dd>
+and the scope operator, or compile using C++11 or later. Defect report 1104
+changed the parser rules so that <code><::</code> works as expected.
+</p></dd>
+
+<dt><code>export</code></dt>
+<dd><p>Most C++ compilers (G++ included) never implemented C++98
+<code>export</code>, which was removed in C++11, and the keyword reused in
+C++20 by the Modules feature. The C++98 feature was intended to support
+separate compilation of template declarations and
+definitions. Without <code>export</code>, a template definition must be in
+scope to be used. The obvious workaround is simply to place all definitions in
+the header itself. Alternatively, the compilation unit containing template
+definitions may be included from the header.</p></dd>
</dl>
<h3 id="upgrading">Common problems when upgrading the compiler</h3>
--
2.41.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wwwdocs: Add ADL to C++ non-bugs
2023-10-03 14:45 [PATCH] wwwdocs: Add ADL to C++ non-bugs Jonathan Wakely
@ 2023-10-04 19:17 ` Jason Merrill
2023-10-05 9:11 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2023-10-04 19:17 UTC (permalink / raw)
To: Jonathan Wakely, gcc-patches
On 10/3/23 10:45, Jonathan Wakely wrote:
> We have a long history of INVALID bugs about std functions being
> available in the global namespace (PRs 27846, 67566, 82619, 99865,
> 110602, 111553, probably others). Let's document it.
>
> Also de-prioritize the C++98-only bugs, which are unlikely to affect
> anybody nowadays.
>
> OK for wwwdocs?
OK, thanks.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wwwdocs: Add ADL to C++ non-bugs
2023-10-04 19:17 ` Jason Merrill
@ 2023-10-05 9:11 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2023-10-05 9:11 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 606 bytes --]
On Wed, 4 Oct 2023 at 20:17, Jason Merrill <jason@redhat.com> wrote:
>
> On 10/3/23 10:45, Jonathan Wakely wrote:
> > We have a long history of INVALID bugs about std functions being
> > available in the global namespace (PRs 27846, 67566, 82619, 99865,
> > 110602, 111553, probably others). Let's document it.
> >
> > Also de-prioritize the C++98-only bugs, which are unlikely to affect
> > anybody nowadays.
> >
> > OK for wwwdocs?
>
> OK, thanks.
>
> Jason
After pushing it I realised the formatting looks bad compared to the
other items in the list, so I've pushed the attached follow-up as
obvious.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1026 bytes --]
commit 1b1a0cf29826ce9287a203cde00fd1512918fc17
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Oct 5 10:09:54 2023 +0100
Add <p> to new item in C++ non-bugs list
diff --git a/htdocs/bugs/index.html b/htdocs/bugs/index.html
index 41edc561..da3d4c0d 100644
--- a/htdocs/bugs/index.html
+++ b/htdocs/bugs/index.html
@@ -541,12 +541,14 @@ for details.
<dl>
<dt>Functions can be called without qualifying them with their namespace.</dt>
<dd>
+<p>
Argument Dependent Lookup (ADL) means that functions can be found in namespaces
associated with their arguments. This means that <code>move(arg)</code> can
call <code>std::move</code> if <code>arg</code> is a type defined in namespace
<code>std</code>, such as <code>std::string</code> or <code>std::vector</code>.
If <code>std::move</code> is not the function you intended to call, use a
qualified name such as <code>::move(arg)</code> or <code>foo::move(arg)</code>.
+</p>
</dd>
<dt>Nested classes can access private members and types of the containing
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-05 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03 14:45 [PATCH] wwwdocs: Add ADL to C++ non-bugs Jonathan Wakely
2023-10-04 19:17 ` Jason Merrill
2023-10-05 9:11 ` Jonathan Wakely
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).