MantisBT - CMake
View Issue Details
0013955CMake(No Category)public2013-02-27 03:392016-06-10 14:31
Mathieu Malaterre 
Bill Hoffman 
normalminorhave not tried
closedmoved 
 
 
0013955: warning: assuming signed overflow does not occur when simplifying conditional to constant
Cmake generates code which confuses gcc optimizer:


/home/mathieu/Perso/gdcm-gcc/Testing/Source/Common/Cxx/gdcmCommonTests.cxx: In function ‘int main(int, char**)’:
/home/mathieu/Perso/gdcm-gcc/Testing/Source/Common/Cxx/gdcmCommonTests.cxx:218: warning: assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]

Code generated by cmake is:

...
  /* If partial match is requested. */
  if(testToRun == -1 && ac > 1)
    {
    partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
    }
...


Looks like gcc thinks ac can be negative...
No tags attached.
Issue History
2013-02-27 03:39Mathieu MalaterreNew Issue
2013-02-27 03:43Mathieu MalaterreNote Added: 0032391
2013-02-27 08:29Brad KingNote Added: 0032392
2013-02-27 08:29Brad KingAssigned To => Bill Hoffman
2013-02-27 08:29Brad KingStatusnew => assigned
2013-02-27 08:42Mathieu MalaterreNote Added: 0032393
2016-06-10 14:28Kitware RobotNote Added: 0042238
2016-06-10 14:28Kitware RobotStatusassigned => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0032391)
Mathieu Malaterre   
2013-02-27 03:43   
Compilation option is:

CXXFLAGS=-O2 -Wstrict-overflow
(0032392)
Brad King   
2013-02-27 08:29   
I can reproduce this with g++ < 4.6 using -O3 -Wstrict-overflow, but not with -O2 or with g++ >= 4.6.

The problem is here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Templates/TestDriver.cxx.in;hb=v2.8.10.2#l72 [^]

in code of the form:

 if(ac < 2)
   {
   ...
   --ac;
   ...
   }

From that gcc concludes it is possible for ac to be negative.
(0032393)
Mathieu Malaterre   
2013-02-27 08:42   
Setup on my side is debian/sid:

$ /usr/bin/c++ --version
c++ (Debian 4.7.2-18) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cd /home/mathieu/Perso/gdcm-schroot/Testing/Source/MessageExchangeDefinition/Cxx && /usr/bin/c++ -Wstrict-overflow -O2 -I/home/mathieu/Perso/gdcm-schroot/Source/Common -I/home/mathieu/Perso/gdcm/Source/Common -I/home/mathieu/Perso/gdcm/Testing/Source/Data -I/home/mathieu/Perso/gdcm-schroot/Testing/Source/Data -I/home/mathieu/Perso/gdcm/Source/DataStructureAndEncodingDefinition -I/home/mathieu/Perso/gdcm/Source/DataDictionary -I/home/mathieu/Perso/gdcm/Source/MediaStorageAndFileFormat -I/home/mathieu/Perso/gdcm/Source/MessageExchangeDefinition -o CMakeFiles/gdcmMEXDTests.dir/gdcmMEXDTests.cxx.o -c /home/mathieu/Perso/gdcm-schroot/Testing/Source/MessageExchangeDefinition/Cxx/gdcmMEXDTests.cxx
/home/mathieu/Perso/gdcm-schroot/Testing/Source/MessageExchangeDefinition/Cxx/gdcmMEXDTests.cxx: In function 'int main(int, char**)':
/home/mathieu/Perso/gdcm-schroot/Testing/Source/MessageExchangeDefinition/Cxx/gdcmMEXDTests.cxx:147:3: warning: assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]
(0042238)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.