Bug 62326 - Instruction Cint fails when converting Hex strings of a negative value to a 16-bit integer value.
Summary: Instruction Cint fails when converting Hex strings of a negative value to a 1...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2013-03-14 08:45 UTC by irs
Modified: 2019-03-27 21:49 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description irs 2013-03-14 08:45:54 UTC
Problem Statement: LibreOffice execution of a BASIC macro stream will fail upon the instruction Cint when converting Hex strings of a negative value to a 16-bit integer value.

Program execution is halted and the error message displayed is: “Inadmissible value or data type. Overflow”.

If the same BASIC code is run on Visual Basic V6.0 or the Visual Basic V6.5 included with MS Office 2003, then it executes without errors.

BASIC code that demonstrates the problem:

Sub Example_Code_For_Integer()
  dim intDecimal as integer

  ' Testing Positive Hex string converted to 16-bit integer - OK
  intDecimal = Cint(&H0)
  msgbox "Cint(&H0): " & Cstr(intDecimal) 
  'should be: 0 - OK

  intDecimal = cint(&H7FFF)
  msgbox "Cint(&H7FFF): " & Cstr(intDecimal) 
  'should be: 32767 - OK

  '=====

  ' Testing Negative Hex string converted to 16-bit integer - Fails 

  intDecimal = Cint(&HFFFF)
  msgbox "Cint(&HFFFF): " & Cstr(intDecimal) 
  'should be: -1 - Fails with Overflow error

  intDecimal = Cint(&H8000)
  msgbox "Cint(&H8000): " & Cstr(intDecimal) 
  'should be: -32768 - Fails with Overflow error

end sub

Note1: The above code was found to fail on the following LibreOffice platforms: 
LibreOffice 4.0.1.2 on WindowsXP SP3
LibreOffice 3.6.2.2 on Ubuntu 12.10 (quantal) 32-bit Linux 3.5.0-21
OpenOffice 3.2.1 on Ubuntu 10.10 (maverick) 32 bit Linux 2.6.35-22 
LibreOffice 3.3.3 Ubuntu 11.04 (natty) 32-bit Linux 2.6.38-11-generic 
LibreOffice 4.0.1.2 on Debian 6.0.7 (squeeze) 64-bit Linux 2.6.32-5-amd64.
 
Note2: I don't have a Mac to test whether or not this problem exists on the Mac / LibreOffice platform.

Note3: I have posted Bug 62323. It is similar to this bug, however it is specific to the LibreOffice Linux 64-bit/AMD release and occurs using when the Clng instruction. 

Regards, ian.
Comment 1 Joel Madero 2013-03-19 20:32:57 UTC
As you have stated the bug existed in an older release I am updating version. Our version field represents the oldest release we see the problem, not the latest it's been tested on - we use comments to say "still exists in version x.x.x.x). Thanks!
Comment 2 irs 2013-03-19 22:55:15 UTC
Hi Joel, 

Thanks for explaining the "Version" field in Bug header section and correcting it to refect the first LibreOffice version release of V3.3.0. 

Cheers, Ian.
Comment 3 Robinson Tryon (qubit) 2013-12-18 18:35:03 UTC
TESTING on LO 4.2.0.0.beta2 on Ubuntu 12.04.3

(In reply to comment #0)
>

Repro steps:
1) Open LO Writer
2) Tools -> Macros -> Organize Macros -> LibreOffice Basic
3) Click on 'Untitled 1', then the 'New' button
4) In the code window that appears, dump the BASIC code (Comment 0) into the file above the opening of the Main sub.
5) Inside the Main sub, call the function;

Sub Main
  Example_Code_For_Integer()
End Sub

6) Run the code (F5)

Result:
See dialog box: "Cint(&H0): 0" with OK button

7) click the OK button

Result:
See dialog box: "Cint(&H7FFF): 32767" with OK button

8) click the OK button

Result:
See dialog box: "Inadmissible value or data type.\nOverflow."

(At this point program execution ended, so we didn't see the last msgBox)

> Program execution is halted and the error message displayed is:
> “Inadmissible value or data type. Overflow”.

Yep.

It's not clear to me if this behavior is as-expected, or is a bug.

> If the same BASIC code is run on Visual Basic V6.0 or the Visual Basic V6.5
> included with MS Office 2003, then it executes without errors.
> 

Interoperability is a strong reason to try to accept this input, even if it does take some development and testing.
Comment 4 irs 2014-01-06 09:01:57 UTC
(In reply to comment #3)
> TESTING on LO 4.2.0.0.beta2 on Ubuntu 12.04.3
> > Program execution is halted and the error message displayed is:
> > “Inadmissible value or data type. Overflow”.
> 
> Yep.
> 
> It's not clear to me if this behavior is as-expected, or is a bug.
> 
> > If the same BASIC code is run on Visual Basic V6.0 or the Visual Basic V6.5
> > included with MS Office 2003, then it executes without errors.
> > 
> 
> Interoperability is a strong reason to try to accept this input, even if it
> does take some development and testing.


Hi Qubit,

I am pleased you can reproduce the "bug". From my latest testing using Linux (64-bit) 3.11.0-15-generic and LibreOffice 4.1.3.2 410m0(Build:2) this Cint() problem still exists.

Please note that this bug regarding the BASIC function Cint() is similar to Bug 62323 which concerned the BASIC function Clng().

Noel Power fixed the problem with Clng() converting negative hex strings by patching /basic/source/comp/scanner.cxx. Maybe additional patching to this scanner.cxx file may fix the problem.

regards, Ian.
Comment 5 tommy27 2016-04-16 07:23:02 UTC Comment hidden (obsolete)
Comment 6 QA Administrators 2017-05-22 13:22:42 UTC Comment hidden (obsolete)
Comment 7 irs 2017-11-27 23:14:11 UTC
Using LO Version: 5.4.1.2 / Build ID: 1:5.4.1-0ubuntu1 I have performed the tests that are in this bugs Description. The bug is still present and the failure messages are still the same.

Regards ian.
Comment 8 QA Administrators 2018-11-28 03:47:32 UTC Comment hidden (obsolete)
Comment 9 irs 2019-03-27 21:49:31 UTC
Hi Using the test method in the original Description posting, the problem still exists with Libreoffice:

Version: 6.0.7.3
Build ID: 1:6.0.7-0ubuntu0.18.04.2
CPU threads: 2; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: en-NZ (en_NZ.UTF-8); Calc: group

regards, Ian.