Skip to content

[2026-06 LWG Motion 6] P3395R6 (Fix encoding issues and add a formatter for std::error_code)#9129

Open
notdanhan wants to merge 1 commit into
cplusplus:mainfrom
notdanhan:motions-2026-06-lwg-6
Open

[2026-06 LWG Motion 6] P3395R6 (Fix encoding issues and add a formatter for std::error_code)#9129
notdanhan wants to merge 1 commit into
cplusplus:mainfrom
notdanhan:motions-2026-06-lwg-6

Conversation

@notdanhan

Copy link
Copy Markdown

Fixes: #9093
Also Fixes cplusplus/papers#2187

@notdanhan notdanhan force-pushed the motions-2026-06-lwg-6 branch from 510ad55 to 4405b34 Compare June 14, 2026 19:06

@eisenwave eisenwave left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a fair amount of work, mainly converting to \grammarterm.

Comment thread source/diagnostics.tex
Equivalent to: \tcode{return os << ec.category().name() << ':' << ec.value();}
\end{itemdescr}

\rSec3[system.error.fmt]{Formatting}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not your fault, but this subclause stable name makes no sense. Everything else is called [syserr.*] except for [system.error.syn].

We probably want something like [syserr.fmt] or whatever the convention is for "formatting support" stable names.

Comment thread source/diagnostics.tex
\rSec3[system.error.fmt]{Formatting}
\pnum
\begin{codeblock}
template<class charT> struct formatter<error_code, charT> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing indexing.

Comment thread source/diagnostics.tex
};
\end{codeblock}

\pnum

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\pnum

Comment thread source/diagnostics.tex
\pnum
\effects
Modifies the state of the \tcode{formatter} to be as if the
\defnx{error-code-format-spec}{error-code-format-spec!syserr err fmt} passed by the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\defnx{error-code-format-spec}{error-code-format-spec!syserr err fmt} passed by the
\grammarterm{error-code-format-spec} passed by the

The paper italics are grammarterm italics, not defining.

Comment thread source/diagnostics.tex
last call to \tcode{parse} contained the \tcode{?} option.
\end{itemdescr}

\pnum

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\pnum

Comment thread source/diagnostics.tex
\opt{fill-and-align} \opt{width} \opt{\tcode{?}} \opt{\tcode{s}}
\end{ncbnf}

where the productions and \defnx{width}{width!format string} are described in\iref{format.string}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
where the productions and \defnx{width}{width!format string} are described in\iref{format.string}
where the productions \grammarterm{fill-and-align} and \grammarterm{width} are described in\iref{format.string}.

Comment thread source/diagnostics.tex
Comment on lines +1306 to +1310
\item If \tcode{charT} is \tcode{char} and the ordinary literal encoding is UTF-8, let
\tcode{msg} be \tcode{ec.message()} transcoded to UTF-8 with maximal subparts of ill-formed
subsequences substituted with \unicode{fffd}{replacement character} per the Unicode Standard, Chapter
3.9 \unicode{fffd} Substitution in Conversion.
\item Otherwise, let \tcode{msg} be \tcode{ec.message()} transcoded to an implementation-defined encoding.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some reflowing:

Suggested change
\item If \tcode{charT} is \tcode{char} and the ordinary literal encoding is UTF-8, let
\tcode{msg} be \tcode{ec.message()} transcoded to UTF-8 with maximal subparts of ill-formed
subsequences substituted with \unicode{fffd}{replacement character} per the Unicode Standard, Chapter
3.9 \unicode{fffd} Substitution in Conversion.
\item Otherwise, let \tcode{msg} be \tcode{ec.message()} transcoded to an implementation-defined encoding.
\item
If \tcode{charT} is \tcode{char} and the ordinary literal encoding is UTF-8,
let \tcode{msg} be \tcode{ec.message()} transcoded to UTF-8
with maximal subparts of ill-formed subsequences substituted with \unicode{fffd}{replacement character}
per the Unicode Standard, Chapter 3.9 \unicode{fffd} Substitution in Conversion.
\item
Otherwise, let \tcode{msg} be \tcode{ec.message()}
transcoded to an implementation-defined encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants