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

[fileio] fix a clang warning about default ctor + const member #234

Merged

Conversation

pmolodo
Copy link
Contributor

@pmolodo pmolodo commented Jan 31, 2020

It seems the strict c++ spec used to state that a const class could only be constructed if it had an explicitly define constructor - even if there was an "obvious" default constructor, that wouldn't leave uninitialized items.

A defect was filed, and later accepted:

http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#253

...but it seems clang, as of Apple clang version 11.0.0, still warns if
you're using --std=c++11

(GCC lets this pass.)

The full error message I got when compiling (using OSX catalina, Apple clang version 11.0.0), was:

In file included from /System/Volumes/Data/Projects/Dev/USD/maya-usd/src/lib/fileio/primUpdater.cpp:17:
/System/Volumes/Data/Projects/Dev/USD/maya-usd/src/lib/fileio/primUpdater.h:40:5: error: explicitly defaulted default constructor is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
    UsdMayaPrimUpdater() = default;
    ^
/System/Volumes/Data/Projects/Dev/USD/maya-usd/src/lib/fileio/primUpdater.h:113:19: note: default constructor of 'UsdMayaPrimUpdater' is implicitly deleted because field '_usdPath' of const-qualified type 'const pxrInternal_v0_20__pxrReserved__::SdfPath' would not be initialized
    const SdfPath _usdPath;
                  ^
1 error generated.

For what it's worth, I only got this when I completely deleted my old build dir, and started a build fresh - perhaps because PXR_STRICT_BUILD_MODE=OFF was cached in CMakeCache.txt?

Definitely a big fan of PXR_STRICT_BUILD_MODE being on, though - it's going to make for some things to fixup like this, but definitely worth it in the long run!

It seems the strict c++ spec used to state that a const class could only
be constructed if it had an explicitly define constructor - even if there
was an "obvious" default constructor, that wouldn't leave uninitialized
items.

A defect was filed, and later accepted:

http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#253

...but it seems clang, as of Apple clang version 11.0.0, still warns if
you're using --std=c++11

(GCC lets this pass.)
@kxl-adsk
Copy link

This change has only 1 file changed - how does it "This migrates the Maya-to-Hydra work from refactoring_sandbox to here." ?

@pmolodo
Copy link
Contributor Author

pmolodo commented Jan 31, 2020

Oops - I think chrome auto-filled my text box from my last PR, and I didn't notice (assuming github was auto-filling with the commit message text, which it usually does when there's one commit). Will fix!

Edit: fixed!

@kxl-adsk kxl-adsk merged commit a29704f into Autodesk:dev Jan 31, 2020
@pmolodo
Copy link
Contributor Author

pmolodo commented Jan 31, 2020

Thanks!

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