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

[BUG]: Typing.h not working with gcc-14 (line 104) #5206

Closed
2 of 3 tasks
97gamjak opened this issue Jun 27, 2024 · 5 comments · Fixed by #5208
Closed
2 of 3 tasks

[BUG]: Typing.h not working with gcc-14 (line 104) #5206

97gamjak opened this issue Jun 27, 2024 · 5 comments · Fixed by #5208
Labels
triage New bug, unverified

Comments

@97gamjak
Copy link

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

v2.13.0 & v2.13.1 & #5203

Problem description

So basically, with tag v 2.13.0 a bug considering the GNU 14 compiler was introduced in typing.h line 104 with std::copy_n

tag v2.12.0 works.

So looking at the changelog of the GNU compiler they state this on how to port the code to gcc-14.

"""
C++ language issues
Header dependency changes
Some C++ Standard Library headers have been changed to no longer include other headers that were being used internally by the library. As such, C++ programs that used standard library components without including the right headers will no longer compile.

The following headers are used less widely in libstdc++ and may need to be included explicitly when compiling with GCC 14:

(for std::copy_n, std::find_if, std::lower_bound, std::remove, std::reverse, std::sort etc.)
...
"""

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

v2.12.0

@ManuelSchneid3r
Copy link
Contributor

ManuelSchneid3r commented Jun 28, 2024

I get

[  116s] /usr/include/pybind11/typing.h:104:58: error: 'copy_n' is not a member of 'std'; did you mean 'copy'?
[  116s]   104 |     constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, name); }
[  116s]       |                                                          ^~~~~~
[  116s]       |                                                          copy

Isnt there just missing an #include <algorithm>?

@97gamjak
Copy link
Author

Yes, but shouldn't this #include be included in the typing.h file?

@Mizux
Copy link

Mizux commented Jul 2, 2024

seems a duplicate of:

TLDR: some versions of gcc seems to miss some c++20 STL template functions...

@rwgk
Copy link
Collaborator

rwgk commented Jul 2, 2024

Yes, but shouldn't this #include be included in the typing.h file?

This was a pybind11 bug (missing include) that was fixed already on master. It'll be in the next release.

$ git show 51c2aa16de5b50fe4be6a0016d6090d4a831899e
commit 51c2aa16de5b50fe4be6a0016d6090d4a831899e
Author: wenqing <wenqing.wang@ufz.de>
Date:   Fri Jun 28 16:12:32 2024 +0200

    Fixed a compilation error with gcc 14 (#5208)

diff --git a/include/pybind11/typing.h b/include/pybind11/typing.h
index c8ba18d4..b0feb946 100644
--- a/include/pybind11/typing.h
+++ b/include/pybind11/typing.h
@@ -14,6 +14,8 @@
 #include "cast.h"
 #include "pytypes.h"

+#include <algorithm>
+
 PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
 PYBIND11_NAMESPACE_BEGIN(typing)

@Mizux
Copy link

Mizux commented Jul 2, 2024

51c2aa1

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

Successfully merging a pull request may close this issue.

4 participants