View Issue Details

IDProjectCategoryView StatusLast Update
0030344Open CASCADEOCCT:Codingpublic2019-06-07 09:29
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformLinuxOSDebian 9 
Product Version7.3.0 
Target Version7.4.0Fixed in Version7.4.0 
Summary0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if
DescriptionGCC 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.
Steps To Reproduce
#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
TagsNo tags attached.
Test case numberNot needed

Relationships

related to 0030692 closedbugmaster Open CASCADE Data Exchange - introduce base framework RWMesh for importing mesh data formats into XDE document 

Activities

git

2018-11-06 16:09

administrator   ~0080765

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

git

2018-11-06 19:56

administrator   ~0080794

Branch CR30344 has been updated forcibly by kgv.

SHA-1: ceb25e8eeafdb81a2373f090fcf8258ce7d799d7

git

2018-11-06 22:32

administrator   ~0080797

Branch CR30344 has been updated forcibly by kgv.

SHA-1: 42c7aac497aee92e41869b0868feb484e95069e7

kgv

2018-11-06 22:33

developer   ~0080798

Last edited: 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/

abv

2018-11-07 12:19

manager   ~0080813

No remarks, please integrate

git

2018-11-11 12:01

administrator   ~0081040

Branch CR30344 has been deleted by inv.

SHA-1: 42c7aac497aee92e41869b0868feb484e95069e7

kgv

2019-06-07 09:29

developer   ~0084942

It seems that this bug has been fixed in GCC 8.

Related Changesets

occt: master 8946be34

2018-11-06 13:07:21

kgv


Committer: bugmaster Details Diff
0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if and Standard_RangeError_Raise_if Affected Issues
0030344
mod - src/Standard/Standard_OutOfRange.hxx Diff File
mod - src/Standard/Standard_RangeError.hxx Diff File

Issue History

Date Modified Username Field Change
2018-11-06 15:48 kgv New Issue
2018-11-06 15:48 kgv Assigned To => kgv
2018-11-06 15:48 kgv Description Updated
2018-11-06 15:49 kgv Description Updated
2018-11-06 15:50 kgv Description Updated
2018-11-06 15:52 kgv Description Updated
2018-11-06 16:07 kgv Summary Coding Rules - eliminate GCC compiler warnings -Wstrict-overflow => Coding Rules - suppress GCC compiler warnings -Wstrict-overflow
2018-11-06 16:08 kgv Summary Coding Rules - suppress GCC compiler warnings -Wstrict-overflow => Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if
2018-11-06 16:09 git Note Added: 0080765
2018-11-06 19:56 git Note Added: 0080794
2018-11-06 22:32 git Note Added: 0080797
2018-11-06 22:33 kgv Note Added: 0080798
2018-11-06 22:33 kgv Assigned To kgv => abv
2018-11-06 22:33 kgv Status new => resolved
2018-11-06 22:33 kgv Note Edited: 0080798
2018-11-07 12:19 abv Note Added: 0080813
2018-11-07 12:19 abv Assigned To abv => bugmaster
2018-11-07 12:19 abv Status resolved => reviewed
2018-11-07 12:41 bugmaster Status reviewed => tested
2018-11-07 13:01 kgv OS Ubuntu 18.04 => Debian 9
2018-11-07 13:01 kgv Description Updated
2018-11-07 13:10 kgv Description Updated
2018-11-09 15:43 bugmaster Test case number => Not needed
2018-11-11 11:52 bugmaster Changeset attached => occt master 8946be34
2018-11-11 11:52 bugmaster Status tested => verified
2018-11-11 11:52 bugmaster Resolution open => fixed
2018-11-11 12:01 git Note Added: 0081040
2019-06-05 13:47 kgv Relationship added related to 0030692
2019-06-07 09:28 kgv Steps to Reproduce Updated
2019-06-07 09:29 kgv Note Added: 0084942