<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://bugreports.qt.io/browse/QTBUG-100845" id="LPNoLPOWALinkPreview">https://bugreports.qt.io/browse/QTBUG-100845</a></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The QWaylandBufferRef class has a very annoying bug in that its relational operators cannot compare `const` objects (only on the RHS). That's because these operators are implemented as members, but are not const. Since they're not const, they cannot be called
 with a const LHS...</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
That's the C++98 picture.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
In C++20, the reversed version of these operators is also considered, which fixes (const == mutable), but makes mutable OP mutable ambiguous (hard error, not a warning).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This makes the operators all but useless in C++20, and awkward to use (swapping RHS and LHS, const_cast'ing) before that.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
For Qt 6.3+, we can fix this by QT_REMOVED_SINCE the member and adding an exported friend op==(const, const): <a href="https://codereview.qt-project.org/c/qt/qtwayland/+/395784" id="LPlnk321072">https://codereview.qt-project.org/c/qt/qtwayland/+/395784</a>
 This is backwards BC. For 6.2 and 5.15, forwards BC is required, though (no new symbols, unless fixing code that didn't compile before).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The problem now is that even if I make use of the didn't-compile-before exception, I still need to add overloads that at least a C++20 compiler would use in lieu of reversed signatures, breaking forward BC also for code that, without the fix, would have compiled.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Example:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
    const QWaylandBufferRef lhs; QWaylandBufferRef rhs;</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
    lhs == rhs; // OK in C++20, fails in C++ < 20</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The last expression currently calls the reversed member-op==. If I add the missing overloads, then it would instead call one of those, one it will not find when going back to an older Qt version. I cannot add the missing overloads as free unexported functions,
 because the member operator hides them and because at least the const, const overloads need to be out-of-line (const_cast is a UB when performed on an object originally declared const), or else we need to break the class' encapsulation by making it inline.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So, I'd like to ask for permission to add the full set of {mut, const} × {==, !=} × {mut, const} to 6.2 and 5.15 (two are present, so six are missing), and then rebasing
<a href="https://codereview.qt-project.org/c/qt/qtwayland/+/395784" id="LPlnk798734">
https://codereview.qt-project.org/c/qt/qtwayland/+/395784</a> onto it to replace this hotfix with the real deal. I cannot use QT_REMOVED_SINCE in 6.2, as it's only available from 6.3.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
If, after all this, the answer is that QtWaylandCompositor isn't under BC constraints, then at least you have learned how terribly complicated such glitches can become.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
If you wish to apply your own gray matter to the problem, <a href="https://codereview.qt-project.org/c/qt/qtwayland/+/395783" id="LPlnk670491">
https://codereview.qt-project.org/c/qt/qtwayland/+/395783</a> contains just the test, to be passed in both C++17 and C++20 modes.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Marc</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<table style="background:rgba(0,0,0,0) none repeat scroll 0% 0%; border:0px none; margin:0px; line-height:0">
<tbody>
<tr>
<td>
<table width="100%">
<tbody>
<tr>
<td style="height:14px"><span style="display:block; height:14px"></span></td>
</tr>
<tr>
<td><span style="display:block; border-bottom:2px solid rgb(181,183,191); height:0px"></span></td>
</tr>
<tr>
<td style="height:14px"><span style="display:block; height:14px"></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="margin:0px; color:rgb(9,9,9); font-size:12px; line-height:18px; font-family:Arial,Helvetica,sans-serif; font-weight:normal">
<p style="margin:0px">Marc Mutz</p>
</td>
</tr>
<tr>
<td style="margin:0px; color:rgb(9,9,9); font-size:12px; line-height:18px; font-family:Arial,Helvetica,sans-serif; font-weight:normal">
<p style="margin:0px">Principal Software Engineer</p>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tbody>
<tr>
<td style="height:7px"><span style="display:block; height:7px"></span></td>
</tr>
<tr>
<td style="height:7px"><span style="display:block; height:7px"></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="margin:0px; color:rgb(9,9,9); font-size:12px; line-height:18px; font-family:Arial,Helvetica,sans-serif">
<p style="margin:0px"><span>The Qt Company</span><br>
<span>Erich-Thilo-Str. 10 12489</span><br>
<span>Berlin, Germany</span></p>
</td>
</tr>
<tr>
<td style="margin:0px; color:rgb(9,9,9); font-size:12px; line-height:18px; font-family:Arial,Helvetica,sans-serif; font-weight:normal">
<p style="margin:0px"><a href="mailto:marc.mutz@qt.io" style="text-decoration:underline">marc.mutz@qt.io</a></p>
</td>
</tr>
<tr>
<td style="margin:0px; color:rgb(9,9,9); font-size:12px; line-height:18px; font-family:Arial,Helvetica,sans-serif; font-weight:normal">
<p style="margin:0px"><a href="https://www.qt.io" style="text-decoration:underline">www.qt.io</a></p>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tbody>
<tr>
<td style="height:7px"><span style="display:block; height:7px"></span></td>
</tr>
<tr>
<td style="height:7px"><span style="display:block; height:7px"></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="margin:0px; color:rgb(9,9,9); font-size:12px; line-height:18px; font-family:Arial,Helvetica,sans-serif">
<p style="margin:0px">Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen</p>
<p style="margin:0px">Sitz der Gesellschaft: Berlin,</p>
<p style="margin:0px">Registergericht: Amtsgericht Charlottenburg,</p>
<p style="margin:0px">HRB 144331 B</p>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tbody>
<tr>
<td style="height:15px"><span style="display:block; height:15px"></span></td>
</tr>
<tr>
<td><span style="display:block; border-bottom:2px solid rgb(181,183,191); height:0px"></span></td>
</tr>
<tr>
<td style="height:20px"><span style="display:block; height:20px"></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="line-height:1"><a href="https://www.qt.io/" target="_blank"><img alt="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/qt-company.png" style="width:160px; height:56px" width="160" height="56" src="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/qt-company.png"></a></td>
</tr>
<tr>
<td style="padding:10px 0px 20px">
<table>
<tbody>
<tr>
<td style="padding:0px 3px 0px 0px"><a href="https://www.facebook.com/qt/" target="_blank"><span><img alt="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/facebook.png" style="width:35px; height:26px" width="35" height="26" src="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/facebook.png"></span></a></td>
<td style="padding:0px 3px 0px 0px"><a href="https://twitter.com/qtproject" target="_blank"><span><img alt="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/twitter.png" style="width:35px; height:26px" width="35" height="26" src="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/twitter.png"></span></a></td>
<td style="padding:0px 3px 0px 0px"><a href="https://www.linkedin.com/company/the-qt-company/" target="_blank"><span><img alt="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/linkedin.png" style="width:35px; height:26px" width="35" height="26" src="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/linkedin.png"></span></a></td>
<td style="padding:0px 3px 0px 0px"><a href="https://www.youtube.com/QtStudios" target="_blank"><span><img alt="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/youtube.png" style="width:35px; height:26px" width="35" height="26" src="https://s3.eu-north-1.amazonaws.com/email-signature-tool-leroy/youtube.png"></span></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<br>
</div>
</div>
</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
</body>
</html>