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

TfRefPtr<TfRefBase> expected unqualified-id before ‘)’ token error when compiling with GCC 12.2.1 and -std=gnu++20 #2183

Closed
expenses opened this issue Jan 20, 2023 · 3 comments

Comments

@expenses
Copy link
Contributor

Description of Issue

usd/include/pxr/base/tf/refPtr.h:1304:25: error: expected unqualified-id before ‘)’ token
 1304 |     TfRefPtr<TfRefBase>() {
      |                         ^
usd/include/pxr/base/tf/refPtr.h:1311:31: error: expected unqualified-id before ‘)’ token
 1311 |     TfRefPtr<const TfRefBase>() {
      |                               ^

Steps to Reproduce

  1. Compile USD on either the release (0c7b9a9) or dev (59eaff4) branch.
  2. Try and include pxr/usd/sdf/layer.h using cxx_std_20 as a cmake compile feature

System Information (OS, Hardware)

  • Arch Linux 6.1.7-arch1-1

If this is just a general case of 'USD doesn't compile with C++ 20' the that's fine, but I wonder how much effort it would take to fix that.

@expenses
Copy link
Contributor Author

I tried just commenting out these lines:

/*
template <>
class TfRefPtr<TfRefBase> {
private:
    TfRefPtr<TfRefBase>() {
    }
};
template <>
class TfRefPtr<const TfRefBase> {
private:
    TfRefPtr<const TfRefBase>() {
    }
};
*/

and it now works fine on C++20 and C++23! Diff: release...expenses:USD:cpp23

I presume these lines are there for a reason (// Specialization: prevent construction of a TfRefPtr<TfRefBase>.). Maybe we can use the preprocessor to only compile them for C++17 and below?

@dubois
Copy link

dubois commented Jan 24, 2023

It looks to me like invalid C++17 that accidentally happens to compile; I suspect the <TfRefBase> should be removed from the ctor definition:

template<> class TfRefPtr<TfRefBase> {
  TfRefPtr() {}
}

@sunyab
Copy link
Contributor

sunyab commented Jan 27, 2023

Filed as internal issue #USD-7903

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

No branches or pull requests

3 participants