Skip to content

[BUG]: Compilation failure with GCC 10.2 on pybind11 2.13.0 (typing.h, line 209) #5201

Description

@zhqrbitee

Required prerequisites

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

2.13.0

Problem description

Environment:

Compiler: GCC 10.2
C++ Language Dialect: C++20 (std=c++20)

Error Message:

In file included from my_venv/include/pybind11/pybind11.h:19,
from my_venv/include/pybind11/numpy.h:12
my_venv/include/pybind11/typing.h:219:49: error: class template argument deduction failed:
219 | struct handle_type_name<typing::Literal<Literals...>> {
| ^~~
compilation terminated due to -Wfatal-errors.

It seems the error just comes from including pybind11 headers and it comes after upgrading to 2.13.

#if defined(__cpp_nontype_template_parameter_class)
template <typing::StringLiteral... Literals>
structhandle_type_name<typing::Literal<Literals...>> {
staticconstexprauto name = const_name("Literal[")
+ pybind11::detail::concat(const_name(Literals.name)...)
+ const_name("]");
};
template <typing::StringLiteral StrLit>
structhandle_type_name<typing::TypeVar<StrLit>> {
staticconstexprauto name = const_name(StrLit.name);
};
#endif

I see it tries to use the macro __cpp_nontype_template_parameter_class to enable some template codes. However not sure why the macro check is success, but GCC 10.2 fails to compile the codes.

Reproducible example code

No response

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

2.12.0

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions