MantisBT - Open CASCADE
View Issue Details
0030344Open CASCADE[OCCT] OCCT:Codingpublic2018-11-06 15:482019-06-07 09:29
kgv 
bugmaster 
normalminor 
verifiedfixed 
LinuxDebian 964 bit
[OCCT] 7.3.0 
[OCCT] 7.4.0* 
Not needed
0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if
GCC produces a lot (~ 140, but they are duplicated) of warnings when building OCCT or OCCT-based project with exceptions in headers using Standard_OutOfRange_Raise_if macros (No_Exception undefined) like this:
/src/NCollection/NCollection_Array1.hxx:379:5: warning: assuming signed overflow does not occur when 
assuming that (X + c) < X is always false [-Wstrict-overflow]
/src/NCollection/NCollection_Array2.hxx:221:5: warning: assuming signed overflow does not occur when 
assuming that (X + c) < X is always false [-Wstrict-overflow]
/src/NCollection/NCollection_BaseVector.hxx:203:22: warning: assuming signed overflow does not occur 
when assuming that (X - c) > X is always false [-Wstrict-overflow]
/src/math/math_Vector.hxx:247:5: warning: assuming signed overflow does not occur when assuming that 
(X + c) < X is always false [-Wstrict-overflow]


The warnings are generated by gcc 4.9, gcc 6.3 and gcc 7.3.
#include <iostream>
#include <cstdlib>
#include <stdexcept>

#if defined(fff) && (defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && 
__GNUC_MINOR__ >= 6))
  #define Standard_OutOfRange_Always_Raise_if(CONDITION, MESSAGE) \
  _Pragma("GCC diagnostic push") \
  _Pragma("GCC diagnostic ignored \"-Wstrict-overflow\"") \
  if (CONDITION) throw std::out_of_range(MESSAGE); \
  _Pragma("GCC diagnostic pop")
#else
  #define Standard_OutOfRange_Always_Raise_if(CONDITION, MESSAGE) \
  if (CONDITION) throw std::out_of_range(MESSAGE);
#endif

#if !defined No_Exception && !defined No_Standard_OutOfRange
  #define Standard_OutOfRange_Raise_if(CONDITION, MESSAGE) Standard_OutOfRange_Always_Raise_if(CONDITION, 
MESSAGE)
#else
  #define Standard_OutOfRange_Raise_if(CONDITION, MESSAGE)
#endif

class MyArray
{
public:
  MyArray (int theLength) : myArray (new double[theLength]), myLength (theLength) {}
  ~MyArray() { delete[] myArray; }

  int Length() const { return myLength; }

  void SetValue (int theIndex, double theValue);
private:
  double* myArray;
  int myLength;
};

inline void MyArray::SetValue (int theIndex, double theValue)
{
  //int aDummy;
  Standard_OutOfRange_Always_Raise_if(theIndex < 0 || theIndex > myLength, "Out of Range");
  
myArray[theIndex - 1] = theValue;
}


void MyFunction (MyArray& theArray)
{
  theArray.SetValue (theArray.Length() - 1, 10.0);
}

int main()
{
  MyArray anArray (10);
  MyFunction (anArray);
  return 0;
}


> g++ test.cxx -Wall -Wextra -O2 -std=gnu++11 -fexceptions
No tags attached.
related to 0029181assigned apn Jenkins Certification Tool - testing with enabled exceptions (undefined No_Exception) 
related to 0030692verified bugmaster Data Exchange - introduce base framework RWMesh for importing mesh data formats into XDE document 
Issue History
2018-11-06 15:48kgvNew Issue
2018-11-06 15:48kgvAssigned To => kgv
2018-11-06 15:48kgvRelationship addedrelated to 0029181
2018-11-06 15:48kgvDescription Updatedbug_revision_view_page.php?rev_id=20317#r20317
2018-11-06 15:49kgvDescription Updatedbug_revision_view_page.php?rev_id=20318#r20318
2018-11-06 15:50kgvDescription Updatedbug_revision_view_page.php?rev_id=20319#r20319
2018-11-06 15:52kgvDescription Updatedbug_revision_view_page.php?rev_id=20320#r20320
2018-11-06 16:07kgvSummaryCoding Rules - eliminate GCC compiler warnings -Wstrict-overflow => Coding Rules - suppress GCC compiler warnings -Wstrict-overflow
2018-11-06 16:08kgvSummaryCoding Rules - suppress GCC compiler warnings -Wstrict-overflow => Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if
2018-11-06 16:09gitNote Added: 0080765
2018-11-06 19:56gitNote Added: 0080794
2018-11-06 22:32gitNote Added: 0080797
2018-11-06 22:33kgvNote Added: 0080798
2018-11-06 22:33kgvAssigned Tokgv => abv
2018-11-06 22:33kgvStatusnew => resolved
2018-11-06 22:33kgvNote Edited: 0080798bug_revision_view_page.php?bugnote_id=80798#r20332
2018-11-07 12:19abvNote Added: 0080813
2018-11-07 12:19abvAssigned Toabv => bugmaster
2018-11-07 12:19abvStatusresolved => reviewed
2018-11-07 12:41bugmasterStatusreviewed => tested
2018-11-07 13:01kgvOSUbuntu 18.04 => Debian 9
2018-11-07 13:01kgvDescription Updatedbug_revision_view_page.php?rev_id=20335#r20335
2018-11-07 13:10kgvDescription Updatedbug_revision_view_page.php?rev_id=20336#r20336
2018-11-09 15:43bugmasterTest case number => Not needed
2018-11-11 11:52bugmasterChangeset attached => occt master 8946be34
2018-11-11 11:52bugmasterStatustested => verified
2018-11-11 11:52bugmasterResolutionopen => fixed
2018-11-11 12:01gitNote Added: 0081040
2019-06-05 13:47kgvRelationship addedrelated to 0030692
2019-06-07 09:28kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=21343#r21343
2019-06-07 09:29kgvNote Added: 0084942

Notes
(0080765)
git   
2018-11-06 16:09   
Branch CR30344 has been created by kgv.

SHA-1: bd8b96b8290113fd5ae6d54eb2db361577c13f58


Detailed log of new commits:

Author: kgv
Date: Tue Nov 6 16:07:21 2018 +0300

    0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if
(0080794)
git   
2018-11-06 19:56   
Branch CR30344 has been updated forcibly by kgv.

SHA-1: ceb25e8eeafdb81a2373f090fcf8258ce7d799d7
(0080797)
git   
2018-11-06 22:32   
Branch CR30344 has been updated forcibly by kgv.

SHA-1: 42c7aac497aee92e41869b0868feb484e95069e7
(0080798)
kgv   
2018-11-06 22:33   
Patch is ready for review.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR30344-master-KGV/view/OCCT%20compile/ [^]

(0080813)
abv   
2018-11-07 12:19   
No remarks, please integrate
(0081040)
git   
2018-11-11 12:01   
Branch CR30344 has been deleted by inv.

SHA-1: 42c7aac497aee92e41869b0868feb484e95069e7
(0084942)
kgv   
2019-06-07 09:29   
It seems that this bug has been fixed in GCC 8.