Archived issue #0032887

Coding - Problem of compilation on VS2019/C++20

Open CASCADEOCCT:Codingassigned84 public notes

Search issues

Description

See attached file

Steps to reproduce

Not required

Public activity

84 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Commenter 2 "Select_Standard.png" - this is normally done by changing `CMAKE_CXX_STANDARD` in CMake configuration:
+ set (CMAKE_CXX_STANDARD 14)


`occt_defs_flags.cmake` currently does this in old-fashion for compatibility with ancient CMake and compilers:
  # Require C++11
  set (CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}")


I don't think that "Latest Draft Standard" should be ever used - drafts are incomplete and their support in compiler is incomplete as well.
02Author
I added to CMake
set (CMAKE_CXX_STANDARD 20)

We get a lot of error and warning and were not able to compile DFBrowser
See attached xlsx file
Attachment 1 (XLSX) (105,876 bytes)
03Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Dmitry DZAMA
Date: Wed Mar 30 12:30:01 2022 +0300

    replace (removed from C++17) `random_shuffle` with `shuffle`
    
    Since C++17 the accessible version of permutation function left the function:
    
    template< class RandomIt, class URBG >
    void shuffle( RandomIt first, RandomIt last, URBG&& g );
    
    See details and example of use: https://en.cppreference.com/w/cpp/algorithm/random_shuffle

Author: Dmitry DZAMA
Date: Wed Mar 30 11:40:11 2022 +0300

    get rid of MSVS compilation error E0349/C2679
    
    In VS 2019/std:c++20 forbidden:
    
    char* str = new char [128];
    std::cin >> str;
    
    But:
    
    char str [128];
    std::str >> str;
    
    is acceptable.

Author: Dmitry DZAMA
Date: Wed Mar 30 10:06:01 2022 +0300

    Warning C5054 operator `&` deprecated between enumerations of different types.

Author: Dmitry DZAMA
Date: Wed Mar 30 09:24:49 2022 +0300

    get rid of std::interator inheritance (depricated since C++17)

Author: Dmitry DZAMA
Date: Tue Mar 29 16:33:45 2022 +0300

    require std:c++20

Author: Dmitry DZAMA
Date: Tue Mar 29 16:32:46 2022 +0300

    get rid of C26451 warning in Standard_Real.hxx
04Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: Dmitry DZAMA
Date: Thu Mar 31 09:21:08 2022 +0300

    so simple and safe functions should be `noexcept`

Author: Dmitry DZAMA
Date: Thu Mar 31 09:19:35 2022 +0300

    use of size_t to loop vector
    
    to get rid of warnings about potentional overflow near `operator+`

Author: Dmitry DZAMA
Date: Thu Mar 31 07:26:39 2022 +0300

    fix uninitialized pointer
05Commenter 1
Commenter 4,
--- a/dox/upgrade/upgrade.md
+++ b/dox/upgrade/upgrade.md
-When compiling code that uses OCCT with GCC and CLang compilers, it is necessary to use compiler option -std=c++0x (or its siblings) to enable C++11 features.
+When compiling code that uses OCCT with GCC and CLang compilers, it is necessary to use compiler option -std=c++20 (or its siblings) to enable C++20 features.

the objective of this bug is not requiring C++20 features for compiling OCCT, but to support both C++11 and C++20 compilation options.

Dmitry DZAMA get rid of C26451 warning in Standard_Real.hxx
inv          Update version up to 7.6.1 OCCT-761 V7_6_1
jgv          0032747: Modeling Algorithms - Exact HLR algorithm... 

Please follow bug advancement workflow:
- First commit in the branch should starts with bug's summary taken from Mantis;
- Patch should be done against `master` branch, not against some old release tag.
https://dev.opencascade.org/doc/overview/html/occt_contribution__contribution_workflow.html
06Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: Dmitry DZAMA
Date: Thu Mar 31 12:41:25 2022 +0300

    get rid of warning C5054 (opearator | between enums of different types)

Author: Dmitry DZAMA
Date: Thu Mar 31 12:28:06 2022 +0300

    get rid of warnings C26451 `Arithmetic overflow...`

Author: Dmitry DZAMA
Date: Thu Mar 31 12:26:31 2022 +0300

    get rid of warnings C26451 `Arithmetic overflow...`

Author: Dmitry DZAMA
Date: Thu Mar 31 11:49:09 2022 +0300

    get rid of warning C5054 (opearator | between enums of different types)

Author: Dmitry DZAMA
Date: Thu Mar 31 11:42:10 2022 +0300

    use `noexcept` for safe func

Author: Dmitry DZAMA
Date: Thu Mar 31 11:40:56 2022 +0300

    fix uninitialized pointer

Author: Dmitry DZAMA
Date: Thu Mar 31 11:01:29 2022 +0300

    get rid of warning C5054 (opearator | between enums of different types)

Author: Dmitry DZAMA
Date: Thu Mar 31 10:46:02 2022 +0300

    disable C4996, C5054 warnings in MSVS for rapidjson library

Author: Dmitry DZAMA
Date: Thu Mar 31 09:58:40 2022 +0300

    get rid of depricated operator & for enums of different types
07Commenter 1
+  using ui = unsigned int;
-      if (theKey == (Aspect_VKey_S | Aspect_VKeyFlags_CTRL))
+      if (theKey == ((ui)Aspect_VKey_S | (ui)Aspect_VKeyFlags_CTRL))

Consider declaring a common type alias `Standard_UInteger` or `Standard_UnsignedInteger` within `Standard_TypeDef.hxx` for reusing in multiple places.
08Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: Dmitry DZAMA
Date: Thu Mar 31 16:18:19 2022 +0300

    disable C26812 `prefere enum class...` warning
09Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: Dmitry DZAMA
Date: Fri Apr 1 08:13:28 2022 +0300

    get rid of warning C5054 (opearator | between enums of different types)
10Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: Dmitry DZAMA
Date: Fri Apr 1 08:42:21 2022 +0300

    get rid of warning C5054 (opearator | between enums of different types)
11Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
12Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
13Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
14Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
15Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
16Commenter 17
AIS_ViewController.cxx::30
#include <cmath> - It seems to be excessive.

RWGltf_GltfJsonParser.hxx::46
In OCCT, we have special headers for warnings disabling. Please take a look at the:
Standard_WarningsDisable.hxx
Standard_WarningsEnable.hxx

NCollection_StlIterator.hxx::32
// Since C++20 inheritance from std::iterator is depricated, so define predefined types manually - misprint `depricated` should be `deprecated`
Please add empty line before starting comment block.

OSD_Parallel.hxx::126
Line is not empty (four spaces).

OSD_Parallel.hxx::127
// Since C++20 inheritance from std::iterator is depricated, so define predefined types manually - misprint `depricated` should be `deprecated`
17Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: Dmitry DZAMA
Date: Mon Apr 4 07:29:42 2022 +0300

    replace `strange` method of defining available character count by simple one.
    
    test bugs fclasses bug31189 faile because of method
    std::stringstream::rdbuf::in_avail() returned 0 for not empty string.
    When test gcc/c++20 has next result:
     - For string "123456789012345" it gets 1.
     - For string "1234567890123456" it gets 16.
    On MSVS 2019/c++20 for string "Sender message 2" it gets 0.
    This is the reason of test failure.
    
    Description of `in_avail` method is some misty, so
    change it to convinient one std::string::empty().
18Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
19Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
20Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
21Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
22Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
23Commenter 1
Commenter 4,

please create subtasks for each kind of issue like
> Coding Rules - eliminate msvc warning C5053 (operator `&` deprecated between enumerations of different types)

and split the patch accordingly, so that each patch could be reviewed and integrated independently.
24Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
25Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
26Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
27Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
28Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
29Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
30Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


No new revisions were added by this update.
31Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: ddzama
Date: Thu Apr 7 15:46:36 2022 +0300

    Merge branches 'CR32903', 'CR32906', 'CR32907', 'CR32908', 'CR32909', 'CR32910', 'CR32916', 'CR32917', 'CR32918', 'CR32919', 'CR32920' and 'CR32921' into CR32887
32Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
33Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
34Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
35Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
36Commenter 37
37Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
38Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: ddzama
Date: Mon Apr 11 12:17:30 2022 +0300

    Fix `if()` contents for employing new cmake policy `CMP0054`, started since version 3.1.
    
    In earlier version of cmake CMP0054 is old.
    If we require version of cmake, started from 3.1, new policy is employing:
    
    set(E "")
    
    By old policy `if("E" STREQUAL "")` is equovalent to `if("" STREQUAL "")`
    
    But in new to `if("E" STREQUAL "")`. E is not replaces with `variable E` and
    considers as text. Variables is used if we use `${variable_name}` explicitly.
    
    See https://cmake.org/cmake/help/latest/policy/CMP0054.html
    for more detais.
39Commenter 1
Commenter 4

 Fix `if()` contents for employing new cmake policy `CMP0054`, started since version 3.1.

Please create a dedicated issue for this and push patch there.
40Commenter 1
Commenter 4
-          if ("${CURRENT_CSF}" STREQUAL "CSF_OpenGlLibs")
+          if ("${CURRENT_CSF}" STREQUAL "${CSF_OpenGlLibs}")

The intent of these lines is to compare $CURRENT_CSF variable with the string value "CSF_OpenGlLibs", and NOT to so-named variable $CSF_OpenGlLibs, so I guess patch breaks this logic.
41Commenter 1
Please also rebase the patch to current master (excluding patches already integrated).
42Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
43Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: ddzama
Date: Wed Apr 20 14:58:42 2022 +0300

    Revert "0032921: require minimum CMAKE version 3.1 (for enabling CMAKE_CXX_STANDARD)"
    
    This reverts [revision removed].
44Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
45Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
46Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
47Commenter 5
Commenter 5
All remarks have been taken into account.
Remind you about jenkins testing result:
http://jenkins-test-occt.nnov.opencascade.com/view/CR32887-master-ddzama/
48Commenter 1
Commenter 4, please switch all individual subtasks to RESOLVED state with meaningful description.
And please proceed REGRESSIONS #0032950 with topmost priority.
49Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
50Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
51Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
52Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
53Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: ddzama
Date: Fri May 6 10:00:04 2022 +0300

    Require old policy for CMP0054
54Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
55Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: ddzama
Date: Fri May 6 14:00:25 2022 +0300

    debuging cmake
56Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
57Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
58Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
59Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
60Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
61Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
62Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: ddzama
Date: Fri May 6 14:50:50 2022 +0300

    f
63Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
64Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
65Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
66Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
67Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
68Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
69Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


No new revisions were added by this update.
70Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
71Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: ddzama
Date: Mon May 30 00:03:01 2022 +0300

    0032887: use std/c++20 as default c++ language standard
72Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
73Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
74Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


No new revisions were added by this update.
75Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
76Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
77Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
78Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
79Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
80Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
81Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
82Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
83Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
84Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]

Related records