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

GCC 12 error: nested_class_wrap.cxx:2058:10: error: anonymous struct with base classes #2145

Closed
marxin opened this issue Jan 18, 2022 · 3 comments
Labels

Comments

@marxin
Copy link

marxin commented Jan 18, 2022

There's a new error reported with GCC 12:

[  126s] checking ruby testcase nested_in_template
[  126s] nested_class_wrap.cxx:2058:10: error: anonymous struct with base classes
[  126s]  2058 |   struct : public InnerMultiple {
[  126s]       |          ^
[  126s] nested_class_wrap.cxx:2062:9: error: anonymous struct with base classes
[  126s]  2062 |   class : public InnerMultiple {
[  126s]       |         ^
[  126s] checking perl5 testcase template_explicit
[  126s] checking ruby testcase nested_scope
[  126s] checking ruby testcase nested_template_base
[  127s] make[2]: *** [../../../Examples/Makefile:1015: ruby_cpp] Error 1
[  127s] make[1]: *** [Makefile:69: nested_class.cpptest] Error 2
@ojwb ojwb added the C++ label Jan 18, 2022
@ojwb
Copy link
Member

ojwb commented Jan 18, 2022

This is literally there in the testcase code rather than being something SWIG generates:

#if defined(__GNUC__) || defined(_MSC_VER) || defined(SWIG)
/* some compilers do not accept these */
  struct : public InnerMultiple {
    Integer xx;
  };

  class : public InnerMultiple {
  public:
    Integer yy;
  };
#else
  Integer xx;
  Integer yy; 
#endif

The GCC commit that added this warning was:

gcc-mirror/gcc@3ead06c#diff-3e4dd2298180728f8241b61e9dbfba81913376c27c636d78d40984723f9c1513

It's unclear to me if this case is actually valid standard C++ or not from a brief look.

@marxin Do you know? I noticed you seem to be a GCC developer while finding the commit above (the most recent commit on the source file where this error is issued was from you).

Some options:

  • We could just drop the first part entirely if this isn't valid standard C++
  • make the conditional #ifdef SWIG
  • make it #if (defined(__GNUC__) && __GNUC__ < 12) || defined(_MSC_VER) || defined(SWIG) (note this will still trigger for all clang versions, since clang always defines __GNUC__ to 4)

@wsfulton
Copy link
Member

Am committing a change using the third option. When/if clang/cl does something similar, we can adjust testcase again.

@marxin
Copy link
Author

marxin commented Jan 19, 2022

It's unclear to me if this case is actually valid standard C++ or not from a brief look.

We newly decided not to support it starting from GCC 12.

@marxin Do you know? I noticed you seem to be a GCC developer while finding the commit above (the most recent commit on the source file where this error is issued was from you).

I'm a GCC developer, but not a C++ front-end developer ;)

Anyway, thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants