Compare with constants, warning XS9021, with /vo4

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Compare with constants, warning XS9021, with /vo4

Post by wriedmann »

Hello,
with the new build I have a lot of warnings about compare operations with Windows API constants, for example:

Code: Select all

case struNotify._Code == HDN_BEGINDRAG
gives a warning

Code: Select all

warning XS9021: Signed/unsigned conversions from 'int' to 'dword' may lead to loss of data or overflow errors
The member _code of struNotify is defined as

Code: Select all

export _code as dword
and the define in the VO Windows API lib seems to be an int.
Strangely enough, this is occurring only on defines, and not on normal ints.
This is a sample:
DefineTester.zip
(1.14 KiB) Downloaded 28 times
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am

Compare with constants, warning XS9021, with /vo4

Post by Karl-Heinz »

Hi Wolfgang,

I also noticed this additional /vo4 behavior. i unchecked the /vo4 setting and in my ownerdraw lib no more XS9021 warnings are thrown. I´ve also tried that with the Hoverlib. But now other warnings and even errors are thrown, But the hoverlib is a (very) special one.

regards
Karl-Heinz
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Compare with constants, warning XS9021, with /vo4

Post by robert »

Wolfgang,

I'll see what I can do.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Compare with constants, warning XS9021, with /vo4

Post by wriedmann »

Hi Robert,
thank you very much!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Kees Bouw
Posts: 97
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

Compare with constants, warning XS9021, with /vo4

Post by Kees Bouw »

Hi,

This warning XS9021 appeared in my code 20 times, in every case in code like this:

LOCAL dwLength AS DWORD
dwLength := SLen(cString)

Since SLen returns a DWORD and dwLength is also a DWORD, I can't explain this warning.

When I change SLen to Len, the warning disappears.

The warning also disappears if I set "Implicit signed/unsigned conversions" to False in the Dialect settings of the project. I would expect the opposite to happen.

I have chosen the last solution to fix this but there is probably something wrong here.

Kind regards,

Kees.
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Compare with constants, warning XS9021, with /vo4

Post by Chris »

Hi Kees,

Yes, this is a bug in the latest X# version, it will be fixed in the next one. Please ignore this warning for now.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply