[PR #4948] [MERGED] Add explicit to bool operators of Point and Rect #26039

Open
opened 2026-01-31 09:13:33 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4948
Author: @carlos-zamora
Created: 3/16/2020
Status: Merged
Merged: 3/19/2020
Merged by: @undefined

Base: masterHead: dev/cazamor/til-explicit-bool


📝 Commits (5)

  • 50f41a0 add explicit to bool operators
  • 28c1ac7 add bool to size, remove bool from point
  • 1911ccf missed a constexpr
  • e65af60 idk why I can't write code today
  • 500ccc6 ok. I actually tested this out this time

📊 Changes

5 files changed (+30 additions, -21 deletions)

View changed files

📝 src/inc/til/point.h (+0 -5)
📝 src/inc/til/rectangle.h (+1 -1)
📝 src/inc/til/size.h (+5 -0)
📝 src/til/ut_til/PointTests.cpp (+0 -15)
📝 src/til/ut_til/SizeTests.cpp (+24 -0)

📄 Description

Found a bug where the following won't work:

COORD inclusiveEnd{ _end };

where _end is a til::point.

The only fix for this is to replace these instances with this:

COORD inclusiveEnd = _end;

What was happening in the first notation is the implicit conversion of til::point to bool to SHORT. The constructor for COORD only sees one SHORT so it thinks the value should be the definition for X, and Y should stay as 0. So we end up getting 1, 0.

By adding the explicit keyword to the bool operators, we prevent the accident above from occurring.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4948 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 3/16/2020 **Status:** ✅ Merged **Merged:** 3/19/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/cazamor/til-explicit-bool` --- ### 📝 Commits (5) - [`50f41a0`](https://github.com/microsoft/terminal/commit/50f41a0fd9d1c95c603b67a442dd2de7c964cdb8) add explicit to bool operators - [`28c1ac7`](https://github.com/microsoft/terminal/commit/28c1ac781f6700f56a5a63e1839e4d02b4639489) add bool to size, remove bool from point - [`1911ccf`](https://github.com/microsoft/terminal/commit/1911ccf612e8afb8dda9aa18a423b68518b35594) missed a constexpr - [`e65af60`](https://github.com/microsoft/terminal/commit/e65af601cd60734078954d0a09181acc08c62673) idk why I can't write code today - [`500ccc6`](https://github.com/microsoft/terminal/commit/500ccc6beeeac23db40954d8110c93587898d437) ok. I actually tested this out this time ### 📊 Changes **5 files changed** (+30 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `src/inc/til/point.h` (+0 -5) 📝 `src/inc/til/rectangle.h` (+1 -1) 📝 `src/inc/til/size.h` (+5 -0) 📝 `src/til/ut_til/PointTests.cpp` (+0 -15) 📝 `src/til/ut_til/SizeTests.cpp` (+24 -0) </details> ### 📄 Description Found a bug where the following won't work: ```c++ COORD inclusiveEnd{ _end }; ``` where `_end` is a `til::point`. The only fix for this is to replace these instances with this: ```c++ COORD inclusiveEnd = _end; ``` What was happening in the first notation is the implicit conversion of `til::point` to `bool` to `SHORT`. The constructor for COORD only sees one SHORT so it thinks the value should be the definition for X, and Y should stay as 0. So we end up getting `1, 0`. By adding the explicit keyword to the bool operators, we prevent the accident above from occurring. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:13:33 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26039