DiscussionsIssue archiveOCCT:Foundation Classes

Archived issue #0029925

Foundation Classes - add missing cast to LowerCase() and UpperCase() arguments

Open CASCADEOCCT:Foundation Classesclosed6 public notes

Search issues

Description

Current implementation of LowerCase()/UpperCase() may trigger issues:
inline Standard_Character LowerCase(const Standard_Character me) 
{ return (Standard_Character)(unsigned char)std::tolower(me); }

inline Standard_Character UpperCase(const Standard_Character me) 
{ return (Standard_Character)(unsigned char)std::toupper(me); }


Note that similar methods IsLowerCase()/IsUpperCase() has necessary cast.

Steps to reproduce

N/A

Public activity

6 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Tue Jul 3 00:45:41 2018 +0300

    0029925: Foundation Classes - add missing cast to LowerCase() and UpperCase() arguments
02Author
03Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: abv
Date: Tue Jul 3 09:43:03 2018 +0300

    Argument of LowerCase() and UpperCase() is cast to int via unsigned char to avoid passing negative integer in the case if the argument char is in the extended part of ASCII table (which would result in undefined behavior according to C++ standard).
    
    Added test bugs fclasses bug29925

04Commenter 4
Reviewed with a test case and commit message added; please integrate
05Commenter 1
Combination -
OCCT branch : [archived branch] SHA - [revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian70-64:
OCCT
Total CPU difference: 17142.029999999697 / 17168.50999999987 [-0.15%]
Products
Total CPU difference: 7474.240000000029 / 7526.93000000002 [-0.70%]
Windows-64-VC10:
OCCT
Total CPU difference: 16875.298974298472 / 16935.000556998602 [-0.35%]
Products
Total CPU difference: 8244.69965029989 / 8215.262261599859 [+0.36%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
06Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]