From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128381 invoked by alias); 5 Nov 2018 19:39:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 128284 invoked by uid 89); 5 Nov 2018 19:39:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=specializations X-HELO: smtp73.ord1d.emailsrvr.com Received: from smtp73.ord1d.emailsrvr.com (HELO smtp73.ord1d.emailsrvr.com) (184.106.54.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Nov 2018 19:39:45 +0000 Received: from smtp10.relay.ord1d.emailsrvr.com (localhost [127.0.0.1]) by smtp10.relay.ord1d.emailsrvr.com (SMTP Server) with ESMTP id 651B9A07E4; Mon, 5 Nov 2018 14:39:44 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=honermann.net; s=20180930-2j89z3ji; t=1541446784; bh=kAO9QF/GsTWVTzoP1//3s/jFu7jIyQhn6KfBIe2StNM=; h=From:Subject:To:Date:From; b=TN0wV/wtVawrPDSvJUhyY5wGFgY7TNCSkrdFM8GmMOi9ODSByKTHzfnUhbA4V+541 K4yoBJyV7BbLkNMxDvR0gwJ1tOjOG2pvwXZQhOUpBv7ArzHbX+OgXRFiy6h4c85+18 r9ohkkNDKddI8GXQfBJRrxZ00gBZCxl1VCiZCAQQ= X-Auth-ID: tom@honermann.net Received: by smtp10.relay.ord1d.emailsrvr.com (Authenticated sender: tom-AT-honermann.net) with ESMTPSA id 05B28A078A; Mon, 5 Nov 2018 14:39:43 -0500 (EST) X-Sender-Id: tom@honermann.net Received: from [10.191.171.177] ([UNAVAILABLE]. [65.50.242.2]) (using TLSv1.2 with cipher AES128-SHA) by 0.0.0.0:25 (trex/5.7.12); Mon, 05 Nov 2018 14:39:44 -0500 From: Tom Honermann Subject: [PATCH 1/9]: C++ P0482R5 char8_t: Documentation updates To: gcc-patches Cc: tom@honermann.net Message-ID: <1de934a1-cc14-26fe-a18c-5de855271187@honermann.net> Date: Mon, 05 Nov 2018 19:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------A41A3086BC748772107BF044" X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg00293.txt.bz2 This is a multi-part message in MIME format. --------------A41A3086BC748772107BF044 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 202 This patch adds documentation for new -fchar8_t and -fno-char8_t options. gcc/ChangeLog: 2018-11-04 Tom Honermann * doc/invoke.texi (-fchar8_t): Document new option. Tom. --------------A41A3086BC748772107BF044 Content-Type: text/x-patch; name="p0482r5-1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="p0482r5-1.patch" Content-length: 2725 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 57491f1033c..cd3a2a715db 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -206,7 +206,7 @@ in the following sections. @item C++ Language Options @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. @gccoptlist{-fabi-version=@var{n} -fno-access-control @gol --faligned-new=@var{n} -fargs-in-order=@var{n} -fcheck-new @gol +-faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new @gol -fconstexpr-depth=@var{n} -fconstexpr-loop-limit=@var{n} @gol -fno-elide-constructors @gol -fno-enforce-eh-specs @gol @@ -2432,6 +2432,53 @@ but few users will need to override the default of This flag is enabled by default for @option{-std=c++17}. +@item -fchar8_t +@itemx -fno-char8_t +@opindex fchar8_t +@opindex fno-char8_t +Enable support for the P0482 proposal including the addition of a +new @code{char8_t} fundamental type, changes to the types of UTF-8 +string and character literals, new signatures for user defined +literals, and new specializations of standard library class templates +@code{std::numeric_limits}, @code{std::char_traits}, +and @code{std::hash}. + +This option enables functions to be overloaded for ordinary and UTF-8 +strings: + +@smallexample +int f(const char *); // #1 +int f(const char8_t *); // #2 +int v1 = f("text"); // Calls #1 +int v2 = f(u8"text"); // Calls #2 +@end smallexample + +and introduces new signatures for user defined literals: + +@smallexample +int operator""_udl1(char8_t); +int v3 = u8'x'_udl1; +int operator""_udl2(const char8_t*, std::size_t); +int v4 = u8"text"_udl2; +template int operator""_udl3(); +int v5 = u8"text"_udl3; +@end smallexample + +The change to the types of UTF-8 string and character literals introduces +incompatibilities with ISO C++11 and later standards. For example, the +following code is well-formed under ISO C++11, but is ill-formed when +@option{-fchar8_t} is specified. + +@smallexample +char ca[] = u8"text"; // error: char-array initialized from wide string +const char *cp = u8"text"; // error: invalid conversion from 'const char8_t*' to 'const char*' +int f(const char*); +auto v = f(u8"text"); // error: invalid conversion from 'const char8_t*' to 'const char*' +std::string s1@{u8"text"@}; // error: no matching function for call to 'std::basic_string::basic_string()' +using namespace std::literals; +std::string s2 = u8"text"s; // error: conversion from 'basic_string' to non-scalar type 'basic_string' requested +@end smallexample + @item -fcheck-new @opindex fcheck-new Check that the pointer returned by @code{operator new} is non-null --------------A41A3086BC748772107BF044--