From a746295cde6bc24f49424f7fc4963e5f36b0458b Mon Sep 17 00:00:00 2001 From: Eisenwave Date: Wed, 30 Sep 2026 07:08:59 +0200 Subject: [PATCH] [diff.expr] Add entry for change in comparison type from int to bool --- source/compatibility.tex | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source/compatibility.tex b/source/compatibility.tex index 5ba3be8773..19e16ac9dc 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -3222,6 +3222,29 @@ \howwide Rare. +\diffref{expr.rel,expr.eq} +\change +Relational and equality comparison expressions are of type \tcode{int} in C, +but of type \tcode{bool} in \Cpp{}. +\rationale +Increased type safety. +\effect +Change to semantics of well-defined feature. +C programs relying on a specific type will yield different results. +\begin{example} +\begin{codeblock} +auto t = (0 == 0); // of type \tcode{int} in C, of type \tcode{bool} in \Cpp{} +bool* b = &t; // valid \Cpp{}, constraint violation in C + +int sum; +ckd_add(&sum, (0 < 0), 1); // valid C, ill-formed \Cpp{}\iref{numerics.c.ckdint} +\end{codeblock} +\end{example} +\difficulty +Programs must add explicit casts to the appropriate type. +\howwide +Rare. + \diffref{expr.cond,expr.assign,expr.comma} \indextext{conversion!lvalue-to-rvalue}% \indextext{rvalue!lvalue conversion to}%