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 build failure with latest glibc #2012

Merged
merged 1 commit into from May 23, 2023

Conversation

ellert
Copy link
Contributor

@ellert ellert commented May 21, 2023

The latest updates to glibc headers adds __nonnull to the fclose()

Declaration in old version:

extern int fclose (FILE *__stream);

Declaration in new version:

extern int fclose (FILE *__stream) __nonnull ((1));

This change causes a compilation error in xrootd:

/builddir/build/BUILD/xrootd-5.5.5/src/XrdTls/XrdTlsTempCA.cc:54:48: error: ignoring attributes on template argument 'int (*)(FILE*)' [-Werror=ignored-attributes]
   54 | typedef std::unique_ptr<FILE, decltype(&fclose)> file_smart_ptr;
      |                                                ^

This commit rewrites the code so the error is not triggered.

src/XrdTls/XrdTlsTempCA.cc Outdated Show resolved Hide resolved
@amadio amadio self-assigned this May 22, 2023
Declaration in old version:

extern int fclose (FILE *__stream);

Declaration in new version:

extern int fclose (FILE *__stream) __nonnull ((1));

This change causes a compilation error in xrootd:

/builddir/build/BUILD/xrootd-5.5.5/src/XrdTls/XrdTlsTempCA.cc:54:48: error: ignoring attributes on template argument 'int (*)(FILE*)' [-Werror=ignored-attributes]
   54 | typedef std::unique_ptr<FILE, decltype(&fclose)> file_smart_ptr;
      |                                                ^

This commit rewrites the code so the error is not triggered.
@amadio amadio merged commit 1c5e3d6 into xrootd:master May 23, 2023
11 of 14 checks passed
@amadio
Copy link
Member

amadio commented May 23, 2023

@ellert Thanks!

@amadio amadio added this to the 5.6 milestone May 23, 2023
@ellert ellert deleted the error-ignored-attributes branch May 23, 2023 11:47
@bbockelm
Copy link
Contributor

@amadio - do you know if there are any recent C++ improvements for code patterns like this? This sort of smart pointer trickery makes me miss the defer keyword in golang.

@amadio
Copy link
Member

amadio commented May 23, 2023

I think it may be possible to use something like std::decay in a case like this, but using the actual type is also fine, I guess.

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

Successfully merging this pull request may close these issues.

None yet

3 participants