-
-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix MSVC C4146 warnings #8366
base: master
Are you sure you want to change the base?
Fix MSVC C4146 warnings #8366
Conversation
The warning description: "unary minus operator applied to unsigned type, result still unsigned".
@@ -432,7 +432,7 @@ void FirstValueWinNode::aggInit(thread_db* tdbb, Request* request) const | |||
|
|||
dsc* FirstValueWinNode::winPass(thread_db* tdbb, Request* request, SlidingWindow* window) const | |||
{ | |||
if (!window->moveWithinFrame(-(window->getRecordPosition() - window->getFrameStart()))) | |||
if (!window->moveWithinFrame(-static_cast<SINT64>(window->getRecordPosition() - window->getFrameStart()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I\d suggest a temporary variable for better readability, e.g.:
const SINT64 offset = window->getRecordPosition() - window->getFrameStart(); // with static_cast, if necessary
if (!window->moveWithinFrame(-offset))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expression window->getRecordPosition() - window->getFrameStart()
used many times, makes sence to move it into separate function, like:
class SlidingWindow
{
public:
...
FB_UINT64 getInFrameOffset() const
{
return savedPosition - frameStart;
}
Perhaps, it should return SINT64
@@ -583,7 +583,7 @@ dsc* NthValueWinNode::winPass(thread_db* tdbb, Request* request, SlidingWindow* | |||
const SLONG fromPos = desc ? MOV_get_long(tdbb, desc, 0) : FROM_FIRST; | |||
|
|||
if (fromPos == FROM_FIRST) | |||
records += -(window->getRecordPosition() - window->getFrameStart()) - 1; | |||
records += -static_cast<SINT64>(window->getRecordPosition() - window->getFrameStart()) - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just -=
with a positive offset here?
The warning description: "unary minus operator applied to unsigned type, result still unsigned".