public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/9]: C++ P0482R5 char8_t: Documentation updates
@ 2018-11-05 19:39 Tom Honermann
  2018-12-03 19:59 ` Jason Merrill
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Tom Honermann @ 2018-11-05 19:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: tom

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

This patch adds documentation for new -fchar8_t and -fno-char8_t options.

gcc/ChangeLog:

2018-11-04  Tom Honermann  <tom@honermann.net>
      * doc/invoke.texi (-fchar8_t): Document new option.

Tom.

[-- Attachment #2: p0482r5-1.patch --]
[-- Type: text/x-patch, Size: 2725 bytes --]

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<char8_t>}, @code{std::char_traits<char8_t>},
+and @code{std::hash<char8_t>}.
+
+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<typename T, T...> 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<char>::basic_string()'
+using namespace std::literals;
+std::string s2 = u8"text"s; // error: conversion from 'basic_string<char8_t>' to non-scalar type 'basic_string<char>' requested
+@end smallexample
+
 @item -fcheck-new
 @opindex fcheck-new
 Check that the pointer returned by @code{operator new} is non-null


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-01-15  4:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-05 19:39 [PATCH 1/9]: C++ P0482R5 char8_t: Documentation updates Tom Honermann
2018-12-03 19:59 ` Jason Merrill
2018-12-05  7:10   ` Tom Honermann
2018-12-05 15:05     ` Jason Merrill
2018-12-11 23:35 ` Sandra Loosemore
2018-12-24  2:28   ` Tom Honermann
2018-12-24  2:27 ` [REVISED PATCH " Tom Honermann
2019-01-05  0:40   ` Martin Sebor
2019-01-15  4:30     ` Tom Honermann

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).