Bug 62326

Summary: Instruction Cint fails when converting Hex strings of a negative value to a 16-bit integer value.
Product: LibreOffice Reporter: irs <irsbugs>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: NEW --- QA Contact:
Severity: normal    
Priority: medium CC: jmadero.dev, qubit
Version: 3.3.0 release   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

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.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.