View Issue Details

IDProjectCategoryView StatusLast Update
0026171Open CASCADEOCCT:Codingpublic2021-12-08 22:41
Reporterkgv Assigned Toinv  
PrioritynormalSeverityminor 
Status verifiedResolutionfixed 
PlatformMacOSOS 
Product Version6.8.0 
Target Version7.7.0 
Summary0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings
DescriptionThere are a bunch of -Wshorten-64-to-32 warnings which should be eliminated:
occt/src/IntPatch/IntPatch_PrmPrmIntersection.cxx:3357:27: warning: implicit conversion loses integer precision: 'unsigned long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
                if(M1.Val(lu) && M2.Val(lu)) {
                   ~~     ^~
occt/src/IntPatch/IntPatch_PrmPrmIntersection.cxx:3357:41: warning: implicit conversion loses integer precision: 'unsigned long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
                if(M1.Val(lu) && M2.Val(lu)) {
                                 ~~     ^~
occt/src/IntPatch/IntPatch_PrmPrmIntersection.cxx:3369:28: warning: implicit conversion loses integer precision: 'unsigned long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
                    M1.Raz(lu);
occt/src/IntPatch/IntPatch_PrmPrmIntersection_T3Bits.cxx:52:45: warning: implicit conversion loses integer precision: 'unsigned long' to 'const Standard_Integer' (aka 'const int') [-Wshorten-64-to-32]
          const Standard_Integer op = (k<<5)|(c);
occt/src/Bnd/Bnd_BoundSortBox.cxx:159:53: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
  void Add(long unsigned t) { int o=t&31;    int k=t>>5;    p[k]|=_P2[o];          }
                                                 ~ ~^~~
occt/src/Bnd/Bnd_BoundSortBox.cxx:160:53: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
  int Val(long unsigned t)  { int o=t&31;    int k=t>>5;    return(p[k]&_P2[o]);   }
                                                 ~ ~^~~
occt/src/Bnd/Bnd_BoundSortBox.cxx:160:72: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
  int Val(long unsigned t)  { int o=t&31;    int k=t>>5;    return(p[k]&_P2[o]);   }
                                                            ~~~~~~ ~~~~^~~~~~~
occt/src/Bnd/Bnd_BoundSortBox.cxx:161:53: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
  void Raz(long unsigned t) { int o=t&31;    int k=t>>5;    p[k]&= ~(_P2[o]);      }
                                                 ~ ~^~~
../../../inc/NCollection_CellFilter.hxx:357:17: warning: implicit conversion loses integer precision: 'const long' to 'int' [-Wshorten-64-to-32]
    int start = theCellMin.index[idim];
        ~~~~~   ^~~~~~~~~~~~~~~~~~~~~~
../../../inc/NCollection_CellFilter.hxx:358:17: warning: implicit conversion loses integer precision: 'const long' to 'int' [-Wshorten-64-to-32]
    int end   = theCellMax.index[idim];
        ~~~     ^~~~~~~~~~~~~~~~~~~~~~
../../../inc/NCollection_CellFilter.hxx:400:17: warning: implicit conversion loses integer precision: 'const long' to 'int' [-Wshorten-64-to-32]
    int start = theCellMin.index[idim];
        ~~~~~   ^~~~~~~~~~~~~~~~~~~~~~
../../../inc/NCollection_CellFilter.hxx:401:17: warning: implicit conversion loses integer precision: 'const long' to 'int' [-Wshorten-64-to-32]
    int end   = theCellMax.index[idim];
        ~~~     ^~~~~~~~~~~~~~~~~~~~~~
../../../inc/NCollection_UtfIterator.lxx:123:54: warning: implicit conversion loses integer precision: 'unsigned long' to 'Standard_Utf32Char' (aka 'unsigned int') [-Wshorten-64-to-32]
            + (aChar2 - UTF16_SURROGATE_LOW_START)   + UTF16_SURROGATE_LOW_BASE;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
../../../inc/Font_FTFont.hxx:168:22: warning: implicit conversion loses integer precision: 'FT_Long' (aka 'long') to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
    return myFTFace->num_glyphs;
    ~~~~~~ ~~~~~~~~~~^~~~~~~~~~
lex.step.c:625:47: warning: implicit conversion loses integer precision: 'yy_size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
      { if (modcom == 0) rec_restext(steptext,stepleng); }
                         ~~~~~~~~~~~          ^~~~~~~~
occt/src/StepSelect/StepSelect_WorkLibrary.cxx:74:10: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  return status;
  ~~~~~~ ^~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:425:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.binfo = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:471:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.einfo = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:553:23: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.bcomment = ftell(myStream);
                    ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:580:23: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.ecomment = ftell(myStream);
                    ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:631:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.btype = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:665:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.etype = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:724:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.broot = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:758:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.eroot = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:818:19: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.bref = ftell(myStream);
                ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:851:19: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.eref = ftell(myStream);
                ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:911:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.bdata = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/FSD/FSD_BinaryFile.cxx:971:20: warning: implicit conversion loses integer precision: 'long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
  myHeader.edata = ftell(myStream);
                 ~ ^~~~~~~~~~~~~~~
occt/src/OSD/OSD_Disk.cxx:71:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    int BSize512 = buffer.f_frsize / 512 ;
        ~~~~~~~~   ~~~~~~~~~~~~~~~~^~~~~
occt/src/OSD/OSD_Disk.cxx:84:36: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
    int BSize512 = buffer.f_frsize / 512 ;
        ~~~~~~~~   ~~~~~~~~~~~~~~~~^~~~~
occt/src/OSD/OSD_File.cxx:303:11: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
 status = read (myFileChannel, readbuf, Nbyte);
        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
occt/src/OSD/OSD_File.cxx:411:12: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
  status = read (myFileChannel, (char*) Buffer, Nbyte);
         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
occt/src/OSD/OSD_File.cxx:445:11: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
 status = write (myFileChannel, writebuf, Nbyte);
        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
occt/src/OSD/OSD_File.cxx:470:12: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
  status = write (myFileChannel, (const char *)Buffer, Nbyte);
         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
occt/src/OSD/OSD_FileNode.cxx:186:17: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
  while ( ( n = read ( fds, buf, BUFSIZE )) >0 )
              ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
occt/src/Standard/Standard_GUID.cxx:277:21: warning: implicit conversion loses integer precision: 'const unsigned long' to 'Standard_Integer' (aka 'int') [-Wshorten-64-to-32]
         my32b  = aWntGuid.Data1;
                ~ ~~~~~~~~~^~~~~



There is a handy system-wide switch in Windows for testing purposes use the MEM_TOP_DOWN registry setting.
This forces all memory allocations to go from the top down, instead of the normal bottom up:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"AllocationPreference"=dword:00100000
Steps To ReproduceCompile using CLang (macOS / Linux / Android) with "-Wshorten-64-to-32" flag added.
Note that this flag has been removed from -Wall/-Wextra since some CLang update.
TagsNo tags attached.
Test case numberN/A

Relationships

related to 0026585 closedbugmaster Open CASCADE Eliminate compile warnings obtained by building occt with vc14: 'type cast' pointer truncation and 'type cast' truncation 
related to 0028198 closedapn Open CASCADE Add FPE signals enabling from CMake 
parent of 0032727 verifiedsmoskvin Open CASCADE Coding Rules - eliminate CLang warning -Wshorten-64-to-32 in MessageView_ActionsTest.cxx 
related to 0026861 closedbugmaster Open CASCADE Configuration, CMake - enable -Wall warnings when using CLang 
related to 0024574 closedbugmaster Open CASCADE ICC compiler warnings on Windows 

Activities

git

2015-04-30 14:31

administrator   ~0040475

Branch CR26171 has been created by kgv.

SHA-1: 0830b01c2ec9664dcef78c98213edcb28aaca59e


Detailed log of new commits:

Author: kgv
Date: Thu Apr 30 14:33:14 2015 +0300

    0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings

rkv

2015-10-15 14:39

developer   ~0046789

The current log doesn't contain these warnings.

Linux log:

http://jenkins-test-02.nnov.opencascade.com/view/CR26585-2-master/job/CR26585-2-master_build_occt_linux/1/consoleFull

Mac log:

http://jenkins-test-02.nnov.opencascade.com/view/CR26585-2-master/job/CR26585-2-master_prepare_build_occt_MacOS/1/consoleFull

kgv

2015-10-15 14:48

developer   ~0046790

adm/cmake/occt_defs_flags.cmake
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()

it does not look like -Wall is specified to CLang compiler when using CMake on OS X. Please check this.

kgv

2015-10-15 14:52

developer   ~0046791

(the log from initial post has been provided when building OCCT using XCode project files, generated by genproj.sh - not CMake)

git

2015-10-30 10:15

administrator   ~0047636

Branch CR26171_1 has been created by rkv.

SHA-1: 2ed27df17d8192d9f0bdcc51474538ee2be10737


Detailed log of new commits:

Author: rkv
Date: Fri Oct 30 09:04:50 2015 +0300

    0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings

git

2015-10-30 10:30

administrator   ~0047638

Branch CR26171 has been updated forcibly by rkv.

SHA-1: d86128e5c286ee0872847ce77827a2fbc1ae7699

git

2015-10-30 11:22

administrator   ~0047642

Branch CR26171 has been updated by rkv.

SHA-1: 0787b82d13a3d78526a17e24ff784dfa459eeb57


Detailed log of new commits:

Author: rkv
Date: Fri Oct 30 10:26:45 2015 +0300

    0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings

git

2015-10-30 11:28

administrator   ~0047643

Branch CR26171 has been updated forcibly by rkv.

SHA-1: bf10d645b08c5d9e4671db9fa49eba8814736edd

git

2015-10-30 11:36

administrator   ~0047644

Branch CR26171_1 has been deleted by rkv.

SHA-1: 2ed27df17d8192d9f0bdcc51474538ee2be10737

git

2021-11-11 01:09

administrator   ~0105094

Branch CR26171_2 has been created by kgv.

SHA-1: db4d960a640127696eb73a51b6a06b62c29a8888


Detailed log of new commits:

Author: rkv
Date: Thu Nov 11 00:06:46 2021 +0300

    0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings

git

2021-11-11 01:10

administrator   ~0105095

Branch CR26171_warn has been created by kgv.

SHA-1: 44ab0e6735e8cbcb46d4936c3d6d82dc08011855


Detailed log of new commits:

Author: rkv
Date: Thu Nov 11 00:06:46 2021 +0300

    0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings
    
    Enable warnings.

git

2021-11-11 01:24

administrator   ~0105096

Branch CR26171_2 has been updated forcibly by kgv.

SHA-1: 793b6f66f62b24017403b96312b06f945f078522

git

2021-11-11 10:34

administrator   ~0105103

Branch CR26171_2 has been updated forcibly by kgv.

SHA-1: 69da5608e7f93a5e4487ae9e2f9585f43ba5f7d6

kgv

2021-11-11 11:42

developer   ~0105110

Please raise the patch
- OCCT: branch CR26171_2.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR26171_2-master-KGV/view/OCCT%20compile/job/CR26171_2-master-KGV-OCCT-MacOS-opt-compile/

bugmaster

2021-11-21 12:30

administrator   ~0105285

Combination -
OCCT branch : IR-2021-11-19
master SHA - ea0ffd6efe2e05d9764495fa0a877ab75ab5f4e9
49e51745631c52b6c452c65adae4d6dfa21a1b1e
Products branch : IR-2021-11-19 SHA - 24ac02cc67913557271bc70687b86b53e78f9c44
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 17763.090000000444 / 17742.320000000425 [+0.12%]
Products
Total CPU difference: 11658.550000000125 / 11669.660000000133 [-0.10%]
Windows-64-VC14:
OCCT
Total CPU difference: 19745.71875 / 19762.140625 [-0.08%]
Products
Total CPU difference: 13066.0625 / 12843.21875 [+1.74%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2021-11-21 13:00

administrator   ~0105297

Branch CR26171 has been deleted by mnt.

SHA-1: bf10d645b08c5d9e4671db9fa49eba8814736edd

git

2021-11-21 13:00

administrator   ~0105298

Branch CR26171_2 has been deleted by mnt.

SHA-1: 69da5608e7f93a5e4487ae9e2f9585f43ba5f7d6

git

2021-11-21 13:00

administrator   ~0105299

Branch CR26171_warn has been deleted by mnt.

SHA-1: 44ab0e6735e8cbcb46d4936c3d6d82dc08011855

Related Changesets

occt: master 57c5e9e8

2021-11-10 21:06:46

rkv


Committer: inv Details Diff
0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings Affected Issues
0026171
mod - adm/cmake/occt_defs_flags.cmake Diff File
mod - adm/qmake/OccCppConfig.pri Diff File
mod - src/Bnd/Bnd_BoundSortBox.cxx Diff File
mod - src/Draw/Draw_Interpretor.cxx Diff File
mod - src/Draw/Draw_Viewer.cxx Diff File
mod - src/Draw/Draw_Window.cxx Diff File
mod - src/Draw/Draw_Window.hxx Diff File
mod - src/Draw/Draw_Window_1.mm Diff File
mod - src/Font/Font_FTFont.cxx Diff File
mod - src/FSD/FSD_BinaryFile.cxx Diff File
mod - src/IntPatch/FILES Diff File
mod - src/IntPatch/IntPatch_PrmPrmIntersection.cxx Diff File
mod - src/IntPatch/IntPatch_PrmPrmIntersection_T3Bits.cxx Diff File
mod - src/IntPatch/IntPatch_PrmPrmIntersection_T3Bits.hxx Diff File
rm - src/IntPatch/IntPatch_PrmPrmIntersection_T3Bits.lxx Diff File
mod - src/NCollection/NCollection_CellFilter.hxx Diff File
mod - src/NCollection/NCollection_UBTreeFiller.hxx Diff File
mod - src/NCollection/NCollection_UtfIterator.hxx Diff File
mod - src/NCollection/NCollection_UtfIterator.lxx Diff File
mod - src/OSD/OSD_Disk.cxx Diff File
mod - src/OSD/OSD_File.cxx Diff File
mod - src/OSD/OSD_FileNode.cxx Diff File
mod - src/QABugs/QABugs_19.cxx Diff File
mod - src/QABugs/QABugs_20.cxx Diff File
mod - src/RWObj/RWObj_Reader.cxx Diff File
mod - src/Standard/Standard_Strtod.cxx Diff File
mod - src/Standard/Standard_UUID.hxx Diff File
mod - src/StepSelect/StepSelect_WorkLibrary.cxx Diff File

Issue History

Date Modified Username Field Change
2015-04-30 14:21 kgv New Issue
2015-04-30 14:21 kgv Assigned To => kgv
2015-04-30 14:21 kgv Target Version 6.9.0 => 7.1.0
2015-04-30 14:31 git Note Added: 0040475
2015-10-14 12:34 kgv Assigned To kgv => rkv
2015-10-14 12:34 kgv Status new => assigned
2015-10-14 12:34 kgv Target Version 7.1.0 => 7.0.0
2015-10-14 12:35 kgv Relationship added related to 0026585
2015-10-15 14:39 rkv Note Added: 0046789
2015-10-15 14:40 rkv Assigned To rkv => abv
2015-10-15 14:48 kgv Note Added: 0046790
2015-10-15 14:48 kgv Assigned To abv => rkv
2015-10-15 14:52 kgv Note Added: 0046791
2015-10-30 10:15 git Note Added: 0047636
2015-10-30 10:30 git Note Added: 0047638
2015-10-30 11:22 git Note Added: 0047642
2015-10-30 11:28 git Note Added: 0047643
2015-10-30 11:29 rkv Assigned To rkv => kgv
2015-10-30 11:29 rkv Status assigned => resolved
2015-10-30 11:29 rkv Steps to Reproduce Updated
2015-10-30 11:36 git Note Added: 0047644
2015-11-11 09:56 kgv Relationship added related to 0026861
2015-12-18 14:47 kgv Target Version 7.0.0 => 7.1.0
2016-11-09 22:27 abv Target Version 7.1.0 => 7.2.0
2017-07-29 12:21 kgv Relationship added related to 0028198
2017-07-29 12:23 kgv Relationship added related to 0024574
2017-07-31 09:17 kgv Description Updated
2017-08-16 15:41 kgv Status resolved => assigned
2017-08-16 15:41 kgv Target Version 7.2.0 => 7.3.0
2018-03-25 12:07 kgv Target Version 7.3.0 => 7.4.0
2019-07-10 19:27 abv Target Version 7.4.0 => 7.5.0
2020-09-11 15:34 utverdov Target Version 7.5.0 => 7.6.0
2021-08-24 14:59 kgv Target Version 7.6.0 => 7.7.0
2021-11-10 23:40 kgv Test case number => N/A
2021-11-10 23:40 kgv Product Version => 6.8.0
2021-11-10 23:40 kgv Steps to Reproduce Updated
2021-11-11 01:09 git Note Added: 0105094
2021-11-11 01:10 git Note Added: 0105095
2021-11-11 01:24 git Note Added: 0105096
2021-11-11 10:34 git Note Added: 0105103
2021-11-11 11:42 kgv Note Added: 0105110
2021-11-11 11:42 kgv Assigned To kgv => bugmaster
2021-11-11 11:42 kgv Status assigned => resolved
2021-11-11 11:43 kgv Status resolved => reviewed
2021-11-21 12:27 bugmaster Status reviewed => tested
2021-11-21 12:30 bugmaster Note Added: 0105285
2021-11-21 12:46 inv Changeset attached => occt master 57c5e9e8
2021-11-21 12:46 inv Assigned To bugmaster => inv
2021-11-21 12:46 inv Status tested => verified
2021-11-21 12:46 inv Resolution open => fixed
2021-11-21 13:00 git Note Added: 0105297
2021-11-21 13:00 git Note Added: 0105298
2021-11-21 13:00 git Note Added: 0105299
2021-12-08 22:41 kgv Relationship added parent of 0032727