Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with constructors on GCC and Clang #31

Closed
wants to merge 2 commits into from

Conversation

aminya
Copy link
Contributor

@aminya aminya commented Dec 3, 2021

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
Copy link
Member

sbaer commented Dec 12, 2021

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

@aminya
Copy link
Contributor Author

aminya commented Dec 12, 2021

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

@sbaer
Copy link
Member

sbaer commented Dec 13, 2021

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

@aminya
Copy link
Contributor Author

aminya commented Dec 13, 2021

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
Copy link
Member

sbaer commented Dec 13, 2021

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
Copy link
Member

sbaer commented Dec 28, 2021

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