MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0026171Open CASCADE[OCCT] OCCT:Codingpublic2015-04-30 14:212018-03-25 12:07
Reporterkgv 
Assigned Tokgv 
PrioritynormalSeverityminor 
StatusassignedResolutionopen 
PlatformMacOSOSOS VersionX
Product Version 
Target Version[OCCT] 7.4.0*Fixed in Version 
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 on Mac OS-X
TagsNo tags attached.
Test case number
Attached Files

- Relationships
related to 0026585closedbugmaster Open CASCADE Eliminate compile warnings obtained by building occt with vc14: 'type cast' pointer truncation and 'type cast' truncation 
related to 0028198closedapn Open CASCADE Add FPE signals enabling from CMake 
related to 0026861closedbugmaster Open CASCADE Configuration, CMake - enable -Wall warnings when using CLang 
related to 0024574closedbugmaster Open CASCADE ICC compiler warnings on Windows 

-  Notes
(0040475)
git (administrator)
2015-04-30 14:31

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
(0046789)
rkv (developer)
2015-10-15 14:39

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 [^]
(0046790)
kgv (developer)
2015-10-15 14:48

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.
(0046791)
kgv (developer)
2015-10-15 14:52

(the log from initial post has been provided when building OCCT using XCode project files, generated by genproj.sh - not CMake)
(0047636)
git (administrator)
2015-10-30 10:15

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
(0047638)
git (administrator)
2015-10-30 10:30

Branch CR26171 has been updated forcibly by rkv.

SHA-1: d86128e5c286ee0872847ce77827a2fbc1ae7699
(0047642)
git (administrator)
2015-10-30 11:22

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

(0047643)
git (administrator)
2015-10-30 11:28

Branch CR26171 has been updated forcibly by rkv.

SHA-1: bf10d645b08c5d9e4671db9fa49eba8814736edd
(0047644)
git (administrator)
2015-10-30 11:36

Branch CR26171_1 has been deleted by rkv.

SHA-1: 2ed27df17d8192d9f0bdcc51474538ee2be10737

- 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 View Revisions
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-29 12:24 kgv Relationship added related to 0028919
2017-07-29 12:25 kgv Relationship added related to 0028918
2017-07-29 12:25 kgv Relationship deleted related to 0028919
2017-07-31 09:17 kgv Description Updated View Revisions
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*


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker