Issue 23882

Summary: testtools linux sparc integer constant is too large for "long" type
Product: porting Reporter: sparcmoz <sparcmoz>
Component: codeAssignee: sparcmoz <sparcmoz>
Status: CLOSED FIXED QA Contact: issues@porting <issues>
Severity: Trivial    
Priority: P3 CC: issues
Version: 680   
Target Milestone: OOo 2.0   
Hardware: Sun   
OS: Linux, all   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
cd testtools; patch -P0 <
none
also needed for cppu/test none

Description sparcmoz 2003-12-26 02:51:28 UTC
Building testtools on linux sparc cws_src680_ooo20031216
bridgetest.cxx:508: error: integer constant is too large for "long" type
line 508 -->
  sal_Int64 _arHyper[] = {0x8000000000000000, 1, 0x7fffffffffffffff};

all the errors-->
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx: In function
`sal_Bool bridge_test::performTest(const
com::sun::star::uno::Reference<com::sun::star::test::bridge::XBridgeTest>&)':
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:375: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:375: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:508: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:508: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:509: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:535: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:535: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:539: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:539: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:543: error:
integer constant is too large for "long" type
/home/jim/680/o2_src/testtools/source/bridgetest/bridgetest.cxx:543: error:
integer constant is too large for "long" type
dmake:  Error code 1, while making '../../unxlngs.pro/slo/bridgetest.obj'
---* TG_SLO.MK *---
 
ERROR: Error 65280 occurred while making
/home/jim/680/o2_src/testtools/source/bridgetest
jim@sun:~/680/o2_src/testtools$
Comment 1 sparcmoz 2003-12-26 03:59:28 UTC
from sal/inc/sal/types.h
#define SAL_MIN_INT64 ((sal_Int64) -0x8000000000000000)
#define SAL_MAX_INT64 ((sal_Int64) 0x7FFFFFFFFFFFFFFF)
Comment 2 sparcmoz 2003-12-26 05:13:28 UTC
Put this code and got the same error: 
sal_Int64 big = (SAL_MAX_INT64) ;
it seems to think sal_Int64 is "long".

Comment 3 sparcmoz 2003-12-26 06:32:59 UTC
I put some "long" data where the testtools expects "long long" and it did build
nicely and the test runs OK in cws_src680_ooo20031216, so i will take this issue
away to porting.

jim@sun:~/680/o2_src/testtools/unxlngs.pro/lib$ ./bridgetest_inprocess
 
 
 ### test succeeded!
 
Comment 4 sparcmoz 2003-12-27 02:45:42 UTC
looks like a compiler error. this code behaves as expected
max + 1 --> negative max (overflow)
but it complains the values are to large for "long"

jim@sun:/usr/local/645/sal$ gcc -o type_test type_test.c
type_test.c: In function `main':
type_test.c:7: warning: integer constant is too large for "long" type
type_test.c:8: warning: integer constant is too large for "long" type
type_test.c:8: warning: integer overflow in expression
type_test.c:9: warning: integer constant is too large for "long" type

jim@sun:/usr/local/645/sal$ cat type_test.c
#include <stdio.h>
typedef long long sal_Int64;
sal_Int64 bit64;
#define SAL_MAX_INT64 ((sal_Int64) 0x7FFFFFFFFFFFFFFF)
int main(void)
{
        bit64 = SAL_MAX_INT64 ;
        printf("max + 1\t =\t%lld\n", SAL_MAX_INT64 + 1);
        printf("max - 1\t =\t %lld\n", SAL_MAX_INT64 - 1);
        printf("max\t =\t %lld, size = %d\n", bit64, sizeof(sal_Int64));
        return(0);
}

jim@sun:/usr/local/645/sal$ ./type_test
max + 1  =      -9223372036854775808
max - 1  =       9223372036854775806
max      =       9223372036854775807, size = 8
jim@sun:/usr/local/645/sal$
Comment 5 sparcmoz 2003-12-27 03:49:13 UTC
From: "Kevin B. Hendricks" <kevin.hendricks@sympatico.ca>
Date: Fri, 26 Dec 2003 22:29:51 -0500
To: dev@porting.openoffice.org
X-Mailer: Apple Mail (2.609)
Subject: Re: [porting-dev] MacOSX now passes pyuno tests.
                                                                                
Hi Jim,
                                                                                
regarding testtools bridgetest ...
                                                                                
I tried this on gcc 3.3 from Apple on a 32 bit MacOSX machine and got
the same warning you got.
                                                                                
Users/kbhend/ooo111a/testtools/source/bridgetest/bridgetest.cxx: In
function `sal_Bool bridge_test::performTest(const
com::sun::star::uno::Reference<com::sun::star::test::bridge::
XBridgeTest>&)':
/Users/kbhend/ooo111a/testtools/source/bridgetest/bridgetest.cxx:338:
warning: integer constant is too large for "long" type
/Users/kbhend/ooo111a/testtools/source/bridgetest/bridgetest.cxx:338:
warning: integer constant is too large for "long" type
Comment 6 sparcmoz 2003-12-27 04:32:40 UTC
Thats it - i put "ll" after those long long values in bridgetest.cxx and it
builds OK.
 
From: Ken Foskey <foskey@optushome.com.au>
To: dev@porting.openoffice.org
X-Mailer: Ximian Evolution 1.4.5
Date: Sat, 27 Dec 2003 15:02:11 +1100
Subject: Re: [porting-dev] MacOSX now passes pyuno tests.
                                                                                
On Sat, 2003-12-27 at 14:47, Jim Watson wrote:
> Thanks Kevin,
>
> I made issue 23882 for this. There i show how to store the
> max value for a "long long" in a variable, and prove it is max by adding +1
> which returns negative max, still the compiler complains. So it may be a
> compiler issue?
                                                                                
There is a macro in sal/types.h that you should be using for this
(Personally I think it is stupid, but...):
                                                                                
   typedef long long           sal_Int64;
   typedef unsigned long long  sal_uInt64;
   //  The following are macros that will add the 64 bit constant
suffix.
#  define SAL_CONST_INT64(x)  x##ll
#  define SAL_CONST_UINT64(x) x##ull
                                                                                
                                                                                
Comment 7 sparcmoz 2004-01-04 20:19:18 UTC
In summary, it appears there is need to include sal/inc/sal/types.h and use
those macros for long long constants. Otherwise the long long will not build on
all platforms? 
Comment 8 sparcmoz 2004-02-11 07:57:01 UTC
Created attachment 13046 [details]
cd testtools; patch -P0 <
Comment 9 sparcmoz 2004-03-15 09:45:23 UTC
Created attachment 13796 [details]
also needed for cppu/test
Comment 10 foskey 2004-03-24 10:36:37 UTC
Approved.  Please commit.
Comment 11 sparcmoz 2004-03-24 11:41:25 UTC
committed in cws_src680_ooo20040329

testtools/source/bridgetest/bridgetest.cxx
cppu/test/test_di.cxx
cppu/test/testcppu.cxx
Comment 12 khendricks 2004-03-24 13:56:02 UTC
Hi Jim,

Looks good to me.

Approved.

Kevin
Comment 13 sparcmoz 2004-10-30 12:18:05 UTC
verified in m59 and closed