Changeset 6a05fd in git


Ignore:
Timestamp:
Oct 29, 2012, 6:31:42 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
Children:
f7286a23b786af032ab46ebb6351640245468492
Parents:
e98ad4a781c85d53c676dffec15b2b238053266718ccf2907a4a103e379cecf364131e83e3aebab5
Message:
Merge pull request #204 from mmklee/factory_imm_mul_sw

chg: avoid undefined signed integer overflow
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Singular/lists.cc

    r18ccf2 r6a05fd  
    2525{
    2626  int n=L->nr;
    27   while ((n>=0)&&(L->m[n].rtyp==DEF_CMD)) n--;
     27   while ((n>=0)&&((L->m[n].rtyp==DEF_CMD)||(L->m[n].rtyp==0))) n--;
    2828  return n;
    2929}
  • Tst/Manual/extgcd.res.gz.uu

    r18ccf2 r6a05fd  
    11begin 644 extgcd.res.gz
    2 M'XL(")Y5BE```V5X=&=C9"YR97,`34\]"\(P%-SS*Q[%H;%I:=+$P6`&<2F(
    3 M2]V*B!^E!$J1-F+\]R:MA"[O#N[N'5>=#^4)`*B"8[F'R(PFZ_0]DN#85??:
    4 MQ%@BCZ`4--:TCV?6-Y]L-#>#JG^:*7=F,6:<T-QE:GK9(J^AFLTL=;28J0C1
    5 MPD<'W;<P['(26_+%I'O)H//%:\M3NW$>EEB!UQ,6>%EE1<(L#X7>D-!02L-3
    6 4H:9Y?L-[C"F6*_0##I4C@@D!````
     2M'XL("."]BE```V5X=&=C9"YR97,`38]+"\(P$(3O^15+\9#8ATV:>#"8@W@I
     3MB)=Z*R(^2@F4(FW$^.]-6BV]S'XP.SML<=KG1P"@"@[Y#@+3FZ31MT""HXMN
     4MM<%$(C]!*:BLJ>^/I*W>26^N!A6_-%-.1A,S'M'494IZWB#OH9*-%#O,1A13
     5M-//13K<U=-LTPC;ZD*AYRLGGL].6QW;M=EAH!5D.,R.S*BM"RZ<ZNF)NPZN7
     69J=KS_[A0PYO^EU>/*9$+]`4-]>F.$0$`````
    77`
    88end
  • Tst/Manual/extgcd.stat

    r18ccf2 r6a05fd  
    1 1 >> tst_memory_0 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:172148
    2 1 >> tst_memory_1 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:2239256
    3 1 >> tst_memory_2 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:2272040
    4 1 >> tst_timer_1 :: 1351243166:3150:3-1-5:ix86-Linux:mamawutz:3
     11 >> tst_memory_0 :: 1351269855:3150:3-1-5:ix86-Linux:mamawutz:172324
     21 >> tst_memory_1 :: 1351269855:3150:3-1-5:ix86-Linux:mamawutz:2239256
     31 >> tst_memory_2 :: 1351269855:3150:3-1-5:ix86-Linux:mamawutz:2272040
     41 >> tst_timer_1 :: 1351269855:3150:3-1-5:ix86-Linux:mamawutz:3
  • factory/imm.h

    re98ad4 r6a05fd  
    3636
    3737#if SIZEOF_LONG == 4
    38 const long MINIMMEDIATE = -268435454; // -2^28-2
     38const long MINIMMEDIATE = -268435454; // -2^28+2
    3939const long MAXIMMEDIATE = 268435454;  // 2^28-2
    4040#else
    41 const long MINIMMEDIATE = -(1L<<60)+2L; // -2^60-2
     41const long MINIMMEDIATE = -(1L<<60)+2L; // -2^60+2
    4242const long MAXIMMEDIATE = (1L<<60)-2L;  // 2^60-2
    4343#endif
     
    300300    long a = imm2int( lhs );
    301301    long b = imm2int( rhs );
    302     INT64 result = (INT64)a * (INT64)b;
     302    int sa= 1;
     303    unsigned INT64 aa, bb;
     304    if (a < 0)
     305    {
     306      sa= -1;
     307      aa= (unsigned INT64) (-a);
     308    }
     309    else
     310      aa= (unsigned INT64) a;
     311    if (b < 0)
     312    {
     313      sa= -sa;
     314      bb= (unsigned INT64) (-b);
     315    }
     316    else
     317      bb= (unsigned INT64) b;
     318    unsigned INT64 result = aa*bb;
    303319    #if SIZEOF_LONG == 4
    304     if ((result>(INT64)MAXIMMEDIATE)||(result<(INT64)MINIMMEDIATE))
     320    if (result>(unsigned INT64)MAXIMMEDIATE)
    305321    {
    306322        InternalCF * res = CFFactory::basic( IntegerDomain, a, true );
     
    308324    }
    309325    #else
    310     if ( ( a!=0L ) && ((result/a!=b)
    311       ||(result>MAXIMMEDIATE)||(result<MINIMMEDIATE) ) )
     326    if ( ( a!=0L ) && ((result/aa!=bb) || (result>(unsigned INT64) MAXIMMEDIATE) ))
    312327    {
    313328        InternalCF * res = CFFactory::basic( IntegerDomain, a, true );
     
    316331    #endif
    317332    else
    318         return int2imm( result );
     333      return int2imm( sa*result );
    319334}
    320335
Note: See TracChangeset for help on using the changeset viewer.