View Issue Details

IDProjectCategoryView StatusLast Update
0031940CommunityOCCT:Foundation Classespublic2022-04-07 14:33
Reporterxuzhongxing Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Platformx86-64OSUbuntu Linux 
Product Version7.1.0 
Target Version7.6.0Fixed in Version7.6.0 
Summary0031940: Foundation Classes - TCollection_ExtendedString::Print() corrupts UNICODE strings and does not compile with C++20
DescriptionC++20 has removed operator<<(std::basic_ostream) overloads accepting char16_t (implicitly converted to integer), leading to TCollection_ExtendedString::Print() compilation error:
    Standard_ExtCharacter c = mystring[i];
      astream << "&#" << c << ";";

This code is obsolete anyway, as OCCT is now expected to print UTF-8 strings to stream.

When compiled with gcc 10.2 -std=gnu++2a
/usr/bin/c++   -I/data1/work/studio/src/ext/opencascade-7.5.0/inc -I/data1/work/studio/src/ext/opencascade-7.5.0/src/inc -I/usr/include/freetype2 -g -march=native   -fPIC -std=gnu++2a -MD -MT src/ext/opencascade-7.5.0/src/CMakeFiles/occt-objs.dir/TCollection/TCollection_ExtendedString.cxx.o -MF src/ext/opencascade-7.5.0/src/CMakeFiles/occt-objs.dir/TCollection/TCollection_ExtendedString.cxx.o.d -o src/ext/opencascade-7.5.0/src/CMakeFiles/occt-objs.dir/TCollection/TCollection_ExtendedString.cxx.o -c /data1/work/studio/src/ext/opencascade-7.5.0/src/TCollection/TCollection_ExtendedString.cxx
/data1/work/studio/src/ext/opencascade-7.5.0/src/TCollection/TCollection_ExtendedString.cxx: In member function ‘void TCollection_ExtendedString::Print(Standard_OStream&) const’:
/data1/work/studio/src/ext/opencascade-7.5.0/src/TCollection/TCollection_ExtendedString.cxx:623:26: error: use of deleted function ‘std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char16_t) [with _Traits = std::char_traits<char>]’
  623 |       astream << "&#" << c << ";";
      |                          ^
In file included from /usr/include/c++/10/iostream:39,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/inc/Standard_Stream.hxx:20,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/inc/Standard_OStream.hxx:19,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/inc/Standard_ExtCharacter.hxx:28,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/inc/Standard_PrimitiveTypes.hxx:27,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/inc/Standard_Transient.hxx:20,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/inc/Standard.hxx:91,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/inc/TCollection_ExtendedString.hxx:20,
                 from /data1/work/studio/src/ext/opencascade-7.5.0/src/TCollection/TCollection_ExtendedString.cxx:15:
/usr/include/c++/10/ostream:549:5: note: declared here
  549 |     operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
      |     ^~~~~~~~
[2743/3480] Building CXX object src/ext/opencascade-...src/CMakeFiles/occt-objs.dir/TopTools/TopTools.cxx.o
ninja: build stopped: subcommand failed.
Steps To ReproduceThe following test command:
static Standard_Integer TestExtString (Draw_Interpretor& theDI,
                                       Standard_Integer ,
                                       const char** theArgVec)
{
  TCollection_AsciiString    aStrUtf8 (theArgVec[1]);
  TCollection_ExtendedString aStrUtf16 (aStrUtf8);
  theDI     << "[DI]   TCollection_AsciiString:    '" << aStrUtf8 << "'\n";
  theDI     << "[DI]   TCollection_ExtendedString: '" << aStrUtf16 << "'\n";
  std::cout << "[cout] TCollection_AsciiString:    '" << aStrUtf8 << "'\n";
  std::cout << "[cout] TCollection_ExtendedString: '" << aStrUtf16 << "'\n";
  return 0;
}

produces the following output:
Draw[2]> TestExtString "What чёрта с два unmöglich français! 你好"
[cout] TCollection_AsciiString:    'What чёрта с два unmöglich français! 你好'
[cout] TCollection_ExtendedString: 'What чёрта с два unmglich franais!  你好'
[DI]   TCollection_AsciiString:    'What чёрта с два unmöglich français! 你好'
[DI]   TCollection_ExtendedString: 'What чёрта с два unmöglich français! 你好'


Note that on printing to cout, the symbols in Latin-1 range are lost ("unmöglich français" -> "unmglich franais"), and symbols in other code ranges are converted to hex values.

It is expected that printing TCollection_ExtendedString should produce the same output as TCollection_AsciiString.
TagsNo tags attached.
Test case numberNot required

Relationships

related to 0031881 closedbugmaster Community Coding Rules - OpenGl_HaltonSampler::initRandom() uses deprecated in C++14 function std::random_shuffle 
child of 0022484 closedbugmaster Open CASCADE UNICODE characters support. 
child of 0027676 closedbugmaster Open CASCADE Foundation Classes - define Standard_ExtCharacter, Standard_Utf16Char using C++11 types char16_t 

Activities

git

2020-11-18 14:56

administrator   ~0096883

Branch CR31940 has been created by kgv.

SHA-1: 91326f8403952d5fa774a8e9c205dfdfc55915e7


Detailed log of new commits:

Author: kgv
Date: Wed Nov 18 14:56:59 2020 +0300

    0031940: Foundation Classes - TCollection_ExtendedString::Print() corrupts UNICODE strings and does not compile with C++20
    
    TCollection_ExtendedString::Print() now converts string into UTF-8
    instead of printing character indexes.

kgv

2020-11-18 16:36

developer   ~0096885

Patch is ready for review
- OCCT branch: CR31940.

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31940-master-KGV/

git

2020-11-22 21:46

administrator   ~0096993

Branch CR31940 has been updated by abv.

SHA-1: d8b9418957333eec73e12ea51e76c6cecd9eb555


Detailed log of new commits:

Author: abv
Date: Sun Nov 22 21:46:52 2020 +0300

    # added description of the change in upgrade.md

abv

2020-11-22 21:47

manager   ~0096994

Reviewed with minor amendment, please integrate

git

2020-11-23 08:18

administrator   ~0096999

Branch CR31940 has been updated forcibly by kgv.

SHA-1: 32a5a77d57cb90920185eecf7ab84e886faa1247

git

2020-11-23 08:18

administrator   ~0097000

Branch CR31940_1 has been created by kgv.

SHA-1: 5e76ae673405ca1bf5c68d864b830e3c904875a4


Detailed log of new commits:

Author: kgv
Date: Wed Nov 18 14:56:59 2020 +0300

    0031940: Foundation Classes - TCollection_ExtendedString::Print() corrupts UNICODE strings and does not compile with C++20
    
    TCollection_ExtendedString::Print() now converts string into UTF-8
    instead of printing character indexes.

bugmaster

2020-11-28 12:45

administrator   ~0097115

Combination -
OCCT branch : IR-2020-11-27
master SHA - 765e5bc192b506e546ba77d881d4929dc0f69b1a
a206de37fbfa0bf71bd534ae47192bbec23b8522
Products branch : IR-2020-11-27 SHA - 17b49a570b557fbeb7326a4adb10fa231b058aed
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:
Debian80-64:
OCCT
Total CPU difference: 18049.94000000008 / 18024.44000000013 [+0.14%]
Products
Total CPU difference: 12325.960000000132 / 12167.95000000011 [+1.30%]
Windows-64-VC14:
OCCT
Total CPU difference: 19703.46875 / 19697.21875 [+0.03%]
Products
Total CPU difference: 13792.6875 / 13647.203125 [+1.07%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2020-11-28 13:05

administrator   ~0097133

Branch CR31940_1 has been deleted by inv.

SHA-1: 5e76ae673405ca1bf5c68d864b830e3c904875a4

git

2020-11-28 13:05

administrator   ~0097134

Branch CR31940 has been deleted by inv.

SHA-1: 32a5a77d57cb90920185eecf7ab84e886faa1247

Related Changesets

occt: master 90e0d12d

2020-11-18 11:56:59

kgv


Committer: bugmaster Details Diff
0031940: Foundation Classes - TCollection_ExtendedString::Print() corrupts UNICODE strings and does not compile with C++20

TCollection_ExtendedString::Print() now converts string into UTF-8
instead of printing character indexes.
Affected Issues
0031940
mod - dox/upgrade/upgrade.md Diff File
mod - src/TCollection/TCollection_ExtendedString.cxx Diff File

Issue History

Date Modified Username Field Change
2020-11-16 12:56 xuzhongxing New Issue
2020-11-16 12:56 xuzhongxing Assigned To => abv
2020-11-18 11:46 kgv Relationship added related to 0031881
2020-11-18 14:55 kgv Target Version => 7.6.0
2020-11-18 14:55 kgv Summary Compiling failure with c++20 => Foundation Classes - TCollection_ExtendedString::Print() corrupts UNICODE strings and does not compile with C++20
2020-11-18 14:55 kgv Steps to Reproduce Updated
2020-11-18 14:56 git Note Added: 0096883
2020-11-18 14:58 kgv Relationship added child of 0022484
2020-11-18 14:59 kgv Relationship added child of 0027676
2020-11-18 14:59 kgv Product Version 7.5.0 => 7.1.0
2020-11-18 14:59 kgv Steps to Reproduce Updated
2020-11-18 15:03 kgv Description Updated
2020-11-18 16:36 kgv Note Added: 0096885
2020-11-18 16:36 kgv Status new => resolved
2020-11-18 16:37 kgv Steps to Reproduce Updated
2020-11-22 10:59 abv Steps to Reproduce Updated
2020-11-22 11:01 abv Steps to Reproduce Updated
2020-11-22 11:02 abv Steps to Reproduce Updated
2020-11-22 11:07 abv Steps to Reproduce Updated
2020-11-22 21:46 git Note Added: 0096993
2020-11-22 21:47 abv Note Added: 0096994
2020-11-22 21:47 abv Assigned To abv => bugmaster
2020-11-22 21:47 abv Status resolved => reviewed
2020-11-23 08:18 git Note Added: 0096999
2020-11-23 08:18 git Note Added: 0097000
2020-11-28 12:45 bugmaster Note Added: 0097115
2020-11-28 12:45 bugmaster Status reviewed => tested
2020-11-28 12:48 bugmaster Test case number => Not required
2020-11-28 12:48 bugmaster Steps to Reproduce Updated
2020-11-28 12:59 bugmaster Changeset attached => occt master 90e0d12d
2020-11-28 12:59 bugmaster Status tested => verified
2020-11-28 12:59 bugmaster Resolution open => fixed
2020-11-28 13:05 git Note Added: 0097133
2020-11-28 13:05 git Note Added: 0097134
2022-03-24 09:57 kgv Relationship added related to 0032887
2022-04-07 14:33 ddzama Relationship deleted related to 0032887