<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 15 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:LMRoman10-Bold;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:LMRoman10-Regular;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:LMMono10-Regular;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:8.0pt;
	margin-left:0cm;
	line-height:107%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
	{margin:0cm;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:8.0pt;
	margin-left:36.0pt;
	line-height:107%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	line-height:107%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	line-height:107%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:8.0pt;
	margin-left:36.0pt;
	line-height:107%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.Code, li.Code, div.Code
	{mso-style-name:Code;
	mso-style-link:"Code Zchn";
	margin-top:6.0pt;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
p.CodeCxSpFirst, li.CodeCxSpFirst, div.CodeCxSpFirst
	{mso-style-name:CodeCxSpFirst;
	mso-style-link:"Code Zchn";
	margin-top:6.0pt;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
p.CodeCxSpMiddle, li.CodeCxSpMiddle, div.CodeCxSpMiddle
	{mso-style-name:CodeCxSpMiddle;
	mso-style-link:"Code Zchn";
	margin:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
p.CodeCxSpLast, li.CodeCxSpLast, div.CodeCxSpLast
	{mso-style-name:CodeCxSpLast;
	mso-style-link:"Code Zchn";
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
span.CodeZchn
	{mso-style-name:"Code Zchn";
	mso-style-link:Code;
	font-family:"Courier New";}
span.Wording
	{mso-style-name:Wording;
	font-family:"Times New Roman",serif;
	color:black;
	font-weight:normal;}
.MsoChpDefault
	{font-family:"Calibri",sans-serif;}
.MsoPapDefault
	{margin-bottom:8.0pt;
	line-height:107%;}
@page WordSection1
	{size:595.3pt 841.9pt;
	margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
	{page:WordSection1;}
 /* List Definitions */
 ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>

</head>

<body lang=EN-GB style='word-wrap:break-word'>

<div class=WordSection1>

<p class=MsoNoSpacing><a name="_Hlk105598784">Document number:&nbsp;  </a>P2624R0</p>

<p class=MsoNoSpacing>Date: 2022-07-06</p>

<p class=MsoNoSpacing>Reply-to: Justin Cooke &lt;jgc@cems.de&gt;<br>
Target audience: CWG</p>

<p class=MsoNormal style='margin-top:6.0pt;line-height:normal'><b><span
style='font-size:12.0pt;font-family:"Times New Roman",serif'>&nbsp;</span></b></p>

<p class=MsoNormal><b><span style='font-size:12.0pt;line-height:107%'>Make operations
on bools more portable </span></b></p>

<p class=MsoNormal><b><span style='font-size:12.0pt;line-height:107%'>&nbsp;</span></b></p>

<p class=MsoNormal><b>Abstract:</b> This proposal is to resolve a contradiction
in the specification of the type <span class=CodeZchn><span style='font-size:
10.0pt;line-height:107%'>bool</span></span> and to tighten the standard so as
to guarantee that: (i) every object of type <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>bool</span></span>, regardless of
provenance, has the value <span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>true</span></span><span style='font-size:12.0pt;line-height:
107%'> </span>or <span class=CodeZchn><span style='font-size:10.0pt;line-height:
107%'>false; </span></span>and (ii) conversion or promotion of <span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>bool</span></span>
to <span class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>int</span></span>
always yields zero or one. The purpose is to ensure that expressions involving
bools yield predictable and unsurprising results that accord with conventional
mathematical logic, so that variables of type <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>bool</span></span> can be used safely
and portably even in safety-critical applications.</p>

<p class=MsoNormal><b>&nbsp;</b></p>

<p class=MsoNoSpacing><b>Motivation:</b>  The C++20 standard (6.8.2<sup>10</sup>)
states: <i><span style='font-size:10.0pt;font-family:LMRoman10-Regular'>Type </span></i><i><span
style='font-size:10.0pt;font-family:LMMono10-Regular'>bool </span></i><i><span
style='font-size:10.0pt;font-family:LMRoman10-Regular'>is a distinct type that
has the same object representation, value representation, and alignment requirements
as an implementation-defined unsigned integer type. The values of type </span></i><span
class=CodeZchn><span style='font-size:9.0pt'>bool</span></span><i><span
style='font-size:10.0pt;font-family:LMMono10-Regular'> </span></i><i><span
style='font-size:10.0pt;font-family:LMRoman10-Regular'>are </span></i><span
class=CodeZchn><span style='font-size:9.0pt'>true</span></span><i><span
style='font-size:10.0pt;font-family:LMMono10-Regular'> </span></i><i><span
style='font-size:10.0pt;font-family:LMRoman10-Regular'>and </span></i><span
class=CodeZchn><span style='font-size:9.0pt'>false</span></span><i><span
style='font-size:10.0pt;font-family:LMRoman10-Regular'>.</span></i><span
style='font-size:10.0pt;font-family:LMRoman10-Regular'> However, i</span>f the <span
class=CodeZchn><span style='font-size:10.0pt'>bool</span></span><span
style='font-size:12.0pt'> </span>type can have just two values, it cannot have
the same <i>value</i> representation as the underlying unsigned integer type,
which can take at least 256 distinct values.  In view of this contradiction, no
implementation can conform exactly to the standard; they approximate the
standard in different ways, with observably different consequences.  Clang
implements <span class=CodeZchn><span style='font-size:10.0pt'>bool</span></span><span
style='font-size:12.0pt'> </span>as if it were a 1-bit bitfield contained in a
1-byte object; only the low-order bit determines the value, while the remaining
bits are padding. Clang’s implementation satisfies the standard’s requirement
that variables of type <span class=CodeZchn><span style='font-size:10.0pt'>bool</span></span><span
style='font-size:12.0pt'> </span>can take just two values (<span
class=CodeZchn><span style='font-size:10.0pt'>true</span></span><span
style='font-size:12.0pt'> </span>and <span class=CodeZchn><span
style='font-size:10.0pt'>false</span></span>) but a clang <span class=CodeZchn><span
style='font-size:10.0pt'>bool</span></span> does not have the same value
representation as the unsigned integer type that contains it. Gcc and msvc
implement the <span class=CodeZchn><span style='font-size:10.0pt'>bool</span></span><span
style='font-size:12.0pt'> </span>type rather as if it were declared <span
style='font-size:12.0pt'>as </span><span class=CodeZchn><span style='font-size:
10.0pt'>enum bool : unsigned char { false, true };</span></span>. The gcc and
msvc implementations satisfy the standard’s requirement that <span
class=CodeZchn><span style='font-size:10.0pt'>bool</span></span><span
style='font-size:12.0pt'> </span>has the same value representation as an unsigned
integer type;  a gcc/msvc <span class=CodeZchn><span style='font-size:10.0pt'>bool</span></span>
can take any of 256 distinct values of which just the first two have special
names.  On conversion or promotion to <span class=CodeZchn><span
style='font-size:10.0pt'>int</span></span>, a clang <span class=CodeZchn><span
style='font-size:10.0pt'>bool</span></span> always yields 0 or 1 (the padding
bits are masked out), while a gcc or msvc <span class=CodeZchn><span
style='font-size:10.0pt'>bool</span></span> yields its <span class=CodeZchn><span
style='font-size:10.0pt'>unsigned char</span></span> value, whatever that
happens to be.  The gcc and msvc implementations differ from each other in
their treatment of some operations on bools. The following code snippets,
tested on gcc 12.1, clang 14.04 and msvc 19.32 illustrate how the three
implementations can yield different results for some functions.  </p>

<p class=MsoNoSpacing>&nbsp;</p>

<p class=MsoNoSpacing>The purpose of this proposal is to ensure that common
expressions involving bools yield predictable and unsurprising results that
accord with conventional mathematical logic, so that variables of type <span
class=CodeZchn><span style='font-size:10.0pt'>bool</span></span> can be used
safely and portably even in safety-critical applications.</p>

<p class=MsoNormal><span style='font-size:10.0pt;line-height:107%;font-family:
LMRoman10-Regular'>&nbsp;</span></p>

<p class=MsoNormal><b>Examples of current behavior:</b></p>

<p class=CodeCxSpFirst>//<span class=Wording><i><span style='font-size:11.0pt;
line-height:107%'>clang always returns 0 or 1; msvc &amp; gcc can return 0, 1
or -1</span></i></span></p>

<p class=CodeCxSpMiddle>int test1(bool b)</p>

<p class=CodeCxSpMiddle>{ switch(b)</p>

<p class=CodeCxSpMiddle>     { case false: return 0;</p>

<p class=CodeCxSpMiddle>       case true: return 1;</p>

<p class=CodeCxSpMiddle>       default: return -1;</p>

<p class=CodeCxSpMiddle>    }</p>

<p class=CodeCxSpMiddle>}</p>

<p class=CodeCxSpMiddle>&nbsp;</p>

<p class=CodeCxSpMiddle>//<span class=Wording><i><span style='font-size:11.0pt;
line-height:107%'>clang &amp; msvc always return 1; gcc can return 1 or 2</span></i></span></p>

<p class=CodeCxSpMiddle>int test2(bool b)</p>

<p class=CodeCxSpMiddle>{ int n = 0;</p>

<p class=CodeCxSpMiddle>  if (b) n++;</p>

<p class=CodeCxSpMiddle>  if (!b) n++;</p>

<p class=CodeCxSpMiddle>  return n;</p>

<p class=CodeCxSpMiddle>}</p>

<p class=CodeCxSpMiddle>&nbsp;</p>

<p class=CodeCxSpMiddle>//<span class=Wording><i><span style='font-size:11.0pt;
line-height:107%'>clang always returns 0 or 2; msvc &amp; gcc can return any even
value from 0 to 510</span></i></span></p>

<p class=CodeCxSpMiddle>int test3(bool b) { return b + b; } </p>

<p class=CodeCxSpMiddle>&nbsp;</p>

<p class=CodeCxSpMiddle>//<span class=Wording><i><span style='font-size:11.0pt;
line-height:107%'>clang &amp; msvc always return 0 or 1; gcc can return any
value from 0 to 255</span></i></span></p>

<p class=CodeCxSpMiddle>int test4(bool b) { return b || b; } </p>

<p class=CodeCxSpLast>&nbsp;</p>

<p class=MsoNormal><b>Note: </b>There are further places where the standard (N4910)
is unclear concerning expressions involving bools:</p>

<p class=MsoNormal><span style='font-family:LMRoman10-Bold'>Section 7.4<sup>1</sup>
Usual arithmetic conversions [expr.arith.conv]<b> </b>states<b> “</b></span><i>The
purpose is to yield a common type, which is also the type of the result.” </i>This
leaves it unclear whether conversions, such as integral promotions, need be performed
when both operands are already of the same type as the result; for example, in the
expression <span class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>a||b</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>where <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>a</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>and <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>b</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>are of type <span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>bool</span></span>.  
Existing implementations interpret this rule differently and yield differing
results for this expression.</p>

<p class=MsoNormal>Section 8.5.2<sup>1</sup> <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>if</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>statements [stmt.if] states:
“<i><span style='font-size:10.0pt;line-height:107%;font-family:LMRoman10-Regular;
color:black'>If the condition (</span></i><i><span style='font-size:10.0pt;
line-height:107%;font-family:LMRoman10-Regular;color:blue'>8.5</span></i><i><span
style='font-size:10.0pt;line-height:107%;font-family:LMRoman10-Regular;
color:black'>) <b>yields </b></span></i><span class=CodeZchn><span
style='font-size:9.0pt;line-height:107%'>true</span></span><i><span
style='font-size:10.0pt;line-height:107%;font-family:LMMono10-Regular;
color:black'> </span></i><i><span style='font-size:10.0pt;line-height:107%;
font-family:LMRoman10-Regular;color:black'>the first substatement is executed.
If the </span></i><i><span style='font-size:10.0pt;line-height:107%;font-family:
LMMono10-Regular;color:black'>else </span></i><i><span style='font-size:10.0pt;
line-height:107%;font-family:LMRoman10-Regular;color:black'>part of the
selection statement is present and the condition <b>yields</b> </span></i><span
class=CodeZchn><span style='font-size:9.0pt;line-height:107%'>false</span></span><i><span
style='font-size:10.0pt;line-height:107%;font-family:LMRoman10-Regular;
color:black'>, the second substatement is executed”. </span></i> It is unclear whether
the word “yields” is supposed to mean “is equal to”.  As the above examples
show, it is possible, given a value <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>b</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>of type <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>bool</span></span>, that both <span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>b</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>and <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>!b</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>yield true in the context of
an <span class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>if</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>condition, while neither <span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>b</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>nor <span class=CodeZchn><span
style='line-height:107%'>!b</span></span> test equal to <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>true</span></span>.</p>

<p class=MsoNoSpacing><b>&nbsp;</b></p>

<p class=MsoNormal><b>Effect on existing code</b>: The behavior of non-portable
code that relies on implementation-specific features may change when the
implementation is brought into conformance with the proposed new standard.  The
clang implementation is already in conformance with the proposed new standard.</p>

<p class=MsoNormal style='margin-top:6.0pt;line-height:normal'><b>&nbsp;</b></p>

<p class=MsoNormal style='margin-top:6.0pt;line-height:normal'><b>Wording: </b>(edits
to N4910)</p>

<p class=MsoNormal><span class=Wording><b>6.8.2 Fundamental types</b>                                                                                [basic.fundamental]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><sup>10</sup> Type </span><span class=CodeZchn><span
style='font-size:9.0pt'>bool</span></span><span class=Wording> is a distinct
type that has the same object representation, <s><span style='background:red'>value
representation,</span></s> and alignment requirements as an
implementation-defined unsigned integer type. The values of type </span><span
class=CodeZchn><span style='font-size:9.0pt'>bool</span></span><span
class=Wording> are </span><span class=CodeZchn><span style='font-size:9.0pt'>true</span></span><span
class=Wording> and </span><span class=CodeZchn><span style='font-size:9.0pt'>false</span></span><span
class=Wording>. <span style='background:lime'>Each possible value of the
unsigned integer type used for the object representation shall be interpreted either
as the value </span></span><span class=CodeZchn><span style='font-size:9.0pt;
background:lime'>true</span></span><span class=Wording><span style='background:
lime'> or as the value </span></span><span class=CodeZchn><span
style='font-size:9.0pt;background:lime'>false</span></span><span class=Wording><span
style='background:lime'> for the type </span></span><span class=CodeZchn><span
style='font-size:9.0pt;background:lime'>bool</span></span><span class=Wording><span
style='background:lime'>.  It is implementation-dependent which values of the
unsigned integer type are interpreted as </span></span><span class=CodeZchn><span
style='font-size:9.0pt;background:lime'>true</span></span><span class=Wording><span
style='background:lime'> and which are interpreted as </span></span><span
class=CodeZchn><span style='font-size:9.0pt;background:lime'>false</span></span><span
class=Wording><span style='background:lime'>, except that the value zero shall necessarily
be interpreted as </span></span><span class=CodeZchn><span style='font-size:
9.0pt;background:lime'>false</span></span><span class=Wording><span
style='background:lime'> and the value one shall necessarily be interpreted as </span></span><span
class=CodeZchn><span style='font-size:9.0pt;background:lime'>true</span></span><span
class=Wording><span style='background:lime'>.</span></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNoSpacing><span class=Wording><b>7.3.7 Integral promotions</b>                                                                                  [conv.prom]</span></p>

<p class=MsoNoSpacing><span class=Wording><sup>6</sup>A prvalue of type </span><span
class=CodeZchn><span style='font-size:9.0pt'>bool</span></span><span
class=Wording> can be converted to a prvalue of type </span><span
class=CodeZchn><span style='font-size:9.0pt'>int</span></span><span
class=Wording>, with </span><span class=CodeZchn><span style='font-size:9.0pt'>false</span></span><span
class=Wording> becoming zero and </span><span class=CodeZchn><span
style='font-size:9.0pt'>true </span></span><span class=Wording>becoming one. <u><span
style='background:lime'>[<i>Note</i>: The result of a promotion from </span></u></span><span
class=CodeZchn><u><span style='font-size:9.0pt;background:lime'>bool</span></u></span><span
class=Wording><u><span style='background:lime'> to </span></u></span><span
class=CodeZchn><u><span style='font-size:9.0pt;background:lime'>int</span></u></span><span
class=Wording><u><span style='background:lime'> is always either zero or one. <i>–
end note</i>]</span> </u></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span style='font-size:10.0pt;font-family:LMRoman10-Regular'>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><b>7.3.9 Integral conversions</b>                                                                              [conv.integral]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><sup>2</sup>If the destination type is </span><span
class=CodeZchn><span style='font-size:9.0pt'>bool</span></span><span
class=Wording>, see 7.3.15. If the source type is </span><span class=CodeZchn><span
style='font-size:9.0pt'>bool</span></span><span class=Wording>, the value </span><span
class=CodeZchn><span style='font-size:9.0pt'>false</span></span><span
class=Wording> is converted to zero and the value </span><span class=CodeZchn><span
style='font-size:9.0pt'>true</span></span><span class=Wording> is converted to
one.  <u><span style='background:lime'>[<i>Note</i>: The result of a conversion
from </span></u></span><span class=CodeZchn><u><span style='font-size:9.0pt;
background:lime'>bool</span></u></span><span class=Wording><u><span
style='background:lime'> to </span></u></span><span class=CodeZchn><u><span
style='font-size:9.0pt;background:lime'>int</span></u></span><span
class=Wording><u><span style='background:lime'> is is always either zero or one.
<i>– end note</i>]</span> </u></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal><span class=Wording><b><span style='font-family:"Calibri",sans-serif'>Implementation
notes</span></b></span><span class=Wording><span style='font-family:"Calibri",sans-serif'>:
The proposed wording would allow an implementation to choose either a clang-like
representation of bools (even number values are </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>false</span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>, odd number
values are </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>true</span></span><span class=Wording><span style='font-family:
"Calibri",sans-serif'>) or a gcc/msvc-like representation (zero is </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>false</span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>, all other values
“yield” </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>true</span></span><span class=Wording><span style='font-family:
"Calibri",sans-serif'>). However, the proposed wording imposes further
requirements that the gcc and msvc implementations do not currently meet. Implementations
may wish to provide a compiler warning for code whose semantics are changed
relative to the existing standard. A vendor may also wish to provide a compiler
switch or pragma to enable their implementation’s legacy semantics for bools,
so that legacy code bases can be used as-is.</span></span></p>

<p class=MsoNormal><span class=Wording><b><span style='font-family:"Calibri",sans-serif'>&nbsp;</span></b></span></p>

<p class=MsoNormal><span class=Wording><b><span style='font-family:"Calibri",sans-serif'>Alternatives</span></b></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>:</span></span></p>

<p class=MsoListParagraphCxSpFirst style='margin-left:54.0pt;text-indent:-36.0pt'><span
class=Wording><span style='font-family:"Calibri",sans-serif'>(i)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><span class=Wording><span style='font-family:"Calibri",sans-serif'>A
minimal resolution of the issue would be to have the standard state that undefined
behavior results whenever the unsigned integer object holding a bool has a
value other than 0 or 1. This option would obviate the need to amend any
existing implementation but, to be fully portable, code would need to check the
value of a </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>bool</span></span><span class=Wording><span style='font-family:
"Calibri",sans-serif'> of unknown provenance before using it, such as by
promoting it to </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>int</span></span><span class=Wording><span style='font-size:
12.0pt;line-height:107%;font-family:"Calibri",sans-serif'> </span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>and converting it
back to </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>bool</span></span><span class=Wording><span style='font-family:
"Calibri",sans-serif'>. </span></span></p>

<p class=MsoListParagraphCxSpLast style='margin-left:54.0pt;text-indent:-36.0pt'><span
class=Wording><span style='font-family:"Calibri",sans-serif'>(ii)<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><span class=Wording><span style='font-family:"Calibri",sans-serif'>A
maximal resolution would be to specify a common representation of bools for all
implementations. This would maximize portability but would involve greater changes
to some implementations’ semantics for bools.</span></span></p>

<p class=MsoNormal style='margin-left:18.0pt'><span class=Wording><span
style='font-family:"Calibri",sans-serif'>&nbsp;</span></span></p>

</div>

</body>

</html>
