View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0030344 | Open CASCADE | OCCT:Coding | public | 2018-11-06 15:48 | 2019-06-07 09:29 |
| Reporter | kgv | Assigned To | bugmaster | ||
| Priority | normal | Severity | minor | ||
| Status | closed | Resolution | fixed | ||
| Platform | Linux | OS | Debian 9 | ||
| Product Version | 7.3.0 | ||||
| Target Version | 7.4.0 | Fixed in Version | 7.4.0 | ||
| Summary | 0030344: Coding Rules - suppress GCC compiler warnings -Wstrict-overflow on Standard_OutOfRange_Raise_if | ||||
| Description | 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. | ||||
| 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 | ||||
| Tags | No tags attached. | ||||
| Test case number | Not needed | ||||
|
|
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 |
|
|
Branch CR30344 has been updated forcibly by kgv. SHA-1: ceb25e8eeafdb81a2373f090fcf8258ce7d799d7 |
|
|
Branch CR30344 has been updated forcibly by kgv. SHA-1: 42c7aac497aee92e41869b0868feb484e95069e7 |
|
|
Patch is ready for review. http://jenkins-test-12.nnov.opencascade.com:8080/view/CR30344-master-KGV/view/OCCT%20compile/ |
|
|
No remarks, please integrate |
|
|
Branch CR30344 has been deleted by inv. SHA-1: 42c7aac497aee92e41869b0868feb484e95069e7 |
|
|
It seems that this bug has been fixed in GCC 8. |
|
occt: master 8946be34 2018-11-06 13:07:21 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 | ||
| 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 |
|
Note Added: 0080813 | |
| 2018-11-07 12:19 |
|
Assigned To | abv => bugmaster |
| 2018-11-07 12:19 |
|
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 |