From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 602BF385700B for ; Wed, 4 Oct 2023 12:47:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 602BF385700B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696423642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TcSVYQxN0BnqJGtR7Lmqhb5osSg38gC6aFFKEAXPEQM=; b=FYP7cRhO5/WVeBTjQ0HhcL4iLRuwplUcpV4dx//al/iPBrvkaCp84WtorKhE2ZCWAL6ioK NF7Y6v7daS9Dhcxbm102vA1n2c7Kn2C/l5U/ZyHY8YKvSVjg4ZuK0EzXT394nCLHOhxysb iHErXM7QPNpP6mBRqrcA0Y/gfGu6JMU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-WP5bKwQuMkyzcSexCEC_WQ-1; Wed, 04 Oct 2023 08:47:20 -0400 X-MC-Unique: WP5bKwQuMkyzcSexCEC_WQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2902C18162D3 for ; Wed, 4 Oct 2023 12:47:20 +0000 (UTC) Received: from localhost (unknown [10.42.28.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB41E1004042; Wed, 4 Oct 2023 12:47:19 +0000 (UTC) From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Cc: Jason Merrill Subject: [PATCH] wwwdocs: Add ADL to C++ non-bugs Date: Tue, 3 Oct 2023 15:45:57 +0100 Message-ID: <20231004124718.3237337-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DATE_IN_PAST_12_24,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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.

C++

-
export
-

Most C++ compilers (G++ included) never implemented C++98 -export, 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 export, 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.

+
Functions can be called without qualifying them with their namespace.
+
+Argument Dependent Lookup (ADL) means that functions can be found in namespaces +associated with their arguments. This means that move(arg) can +call std::move if arg is a type defined in namespace +std, such as std::string or std::vector. +If std::move is not the function you intended to call, use a +qualified name such as ::move(arg) or foo::move(arg). +
Nested classes can access private members and types of the containing class.
@@ -597,9 +597,9 @@ handler and catch it in the main thread.

If you have a class in the global namespace, say named X, and want to give it as a template argument to some other class, say std::vector, then std::vector<::X> -fails with a parser error.

+fails with a parser error in C++98/C++03 mode.

-

The reason is that the standard mandates that the sequence +

The reason is that the C++98 standard mandates that the sequence <: is treated as if it were the token [. (There are several such combinations of characters - they are called digraphs.) Depending on the version, the compiler then reports @@ -608,7 +608,19 @@ a parse error before the character : (the colon before

The simplest way to avoid this is to write std::vector< ::X>, i.e. place a space between the opening angle bracket -and the scope operator.

+and the scope operator, or compile using C++11 or later. Defect report 1104 +changed the parser rules so that <:: works as expected. +

+ +
export
+

Most C++ compilers (G++ included) never implemented C++98 +export, 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 export, 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.

Common problems when upgrading the compiler

-- 2.41.0