[Libreoffice-bugs] [Bug 130476] New: BASIC: Data Type Characters with literals don't affect resulting value type

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Thu Feb 6 06:50:50 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=130476

            Bug ID: 130476
           Summary: BASIC: Data Type Characters with literals don't affect
                    resulting value type
           Product: LibreOffice
           Version: Inherited From OOo
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: mikekaganski at hotmail.com

Consider this code:


> sub typesnames
>   ' Integer % - doesn't work, Long &
>   ' This should print Integer Long, but prints Integer Integer
>   MsgBox TypeName(&hff) & " " & TypeName(&hff&)
> end sub

As mentioned in comment, is should output "Integer Long", but gives "Integer
Integer" instead. The trailing data type characters # and & at the literals
should explicitly define the type of the literal, instead of using the default
handling depending on the value of the number.

The code works in Excel as expected, taking value type characters into account.

The impact of the problem is that it's impossible to explicitly define the size
of the value, e.g. when using bitwise operations. Consider the following code:

> Sub ApplyMask
>   a = &h0F0F0F0F&
>   b = &h0000FF00&
>   MsgBox "&h" & Hex(a And b)
> End Sub

The code applies the mask b to number a, and is expected to output "&hF00", but
actually outputs "&hF0F0F00", because b is handled as Integer, which is
negative, which then gets converted into corresponding negative Long when used
in bitwise "And", with all higher bits set, which distorts the mask into
&hFFFFFF00&.

Tested with Version: 6.4.0.3 (x64)
Build ID: b0a288ab3d2d4774cb44b62f04d5d28733ac6df8
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: GL; VCL: win; 
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: CL

and with OpenOffice.org 3.2.0
OOO320m12 (Build:9483)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200206/5ee907b7/attachment.htm>


More information about the Libreoffice-bugs mailing list