Skip to content

Fix issues with constructors on GCC and Clang - #31

Closed
aminya wants to merge 2 commits into
mcneel:7.xfrom
aminya:clang-constructor
Closed

Fix issues with constructors on GCC and Clang#31
aminya wants to merge 2 commits into
mcneel:7.xfrom
aminya:clang-constructor

Conversation

@aminya

@aminya aminya commented Dec 3, 2021

Copy link
Copy Markdown
Contributor

Cherry-picked from #28

  • It fixes the bugs related to not-initializing constants where default constructors are defaulted
/home/aminya/opennurbs/opennurbs_statics.cpp:747:21: error: uninitialized const ‘ON_AngleValue::Unset’ [-fpermissive]
  747 | const ON_AngleValue ON_AngleValue::Unset ON_CLANG_CONSTRUCTOR_BUG_INIT(ON_AngleValue);
      |                     ^~~~~~~~~~~~~
In file included from /home/aminya/opennurbs/opennurbs.h:81,
                 from /home/aminya/opennurbs/opennurbs_statics.cpp:1:
/home/aminya/opennurbs/opennurbs_string_value.h:274:16: note: ‘const class ON_AngleValue’ has no user-provided default constructor
  274 | class ON_CLASS ON_AngleValue
      |                ^~~~~~~~~~~~~
/home/aminya/opennurbs/opennurbs_string_value.h:277:3: note: constructor is not user-provided because it is explicitly defaulted in the class body
  277 |   ON_AngleValue() = default;
      |   ^~~~~~~~~~~~~

Fixes
```
/home/aminya/opennurbs/opennurbs_statics.cpp:747:21: error: uninitialized const ‘ON_AngleValue::Unset’ [-fpermissive]
  747 | const ON_AngleValue ON_AngleValue::Unset ON_CLANG_CONSTRUCTOR_BUG_INIT(ON_AngleValue);
      |                     ^~~~~~~~~~~~~
In file included from /home/aminya/opennurbs/opennurbs.h:81,
                 from /home/aminya/opennurbs/opennurbs_statics.cpp:1:
/home/aminya/opennurbs/opennurbs_string_value.h:274:16: note: ‘const class ON_AngleValue’ has no user-provided default constructor
  274 | class ON_CLASS ON_AngleValue
      |                ^~~~~~~~~~~~~
/home/aminya/opennurbs/opennurbs_string_value.h:277:3: note: constructor is not user-provided because it is explicitly defaulted in the class body
  277 |   ON_AngleValue() = default;
      |   ^~~~~~~~~~~~~
```
@sbaer

sbaer commented Dec 12, 2021

Copy link
Copy Markdown
Member

Is there a specific build that this is causing errors with?

@aminya

aminya commented Dec 12, 2021

Copy link
Copy Markdown
Contributor Author

Yes. Building with Clang or GCC causes the error I mentioned above.

@sbaer

sbaer commented Dec 13, 2021

Copy link
Copy Markdown
Member

Is there a specific platform combination where this was not working? We compile with Xcode on OSX and GCC/Clang on Linux

@aminya

aminya commented Dec 13, 2021

Copy link
Copy Markdown
Contributor Author

Maybe the compilers you test with are not the recent versions. I can set up a GitHub Action CI system if you really want to see which combinations are failing to build opennurbs.

The ones I tested this with:
Clang 13 Windows
Clang 13 Linux
Gcc 9 Linux

This ON_CLANG_CONSTRUCTOR_BUG_INIT hack also causes a huge number of warnings on Clang due to the calls to the deleted functions. That's why I added this line in the CMakeLists.txt file

@sbaer

sbaer commented Dec 13, 2021

Copy link
Copy Markdown
Member

I'm sure this macro was from XCode as the comments in the ON_CLANG_CONSTRUCTOR_BUG_INIT marcro declaration alludes to. We'll need to test to see what the latest version of XCode does now.

@sbaer

sbaer commented Dec 28, 2021

Copy link
Copy Markdown
Member

I tried fixing this in a different way. It turns out the two classes in question did not have initial values set for all of their members which would cause the compile error on clang. Here's the PR
#36
ON_CLANG_CONSTRUCTOR_BUG is no longer defined which means
ON_CLANG_CONSTRUCTOR_BUG_INIT(ctor) resolves to nothing

@sbaer sbaer closed this Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants