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]: Errors in VS 2022 and c++ 20 #3824

Open
3 tasks done
AhmedZero opened this issue Mar 24, 2022 · 5 comments
Open
3 tasks done

[BUG]: Errors in VS 2022 and c++ 20 #3824

AhmedZero opened this issue Mar 24, 2022 · 5 comments

Comments

@AhmedZero
Copy link

Required prerequisites

Problem description

when i build with pybind11, it failed to build
i use Visual Studio 2022 and C++ 20

##Errors

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2678	binary '-': no operator found which takes a left-hand operand of type 'const L' (or there is no acceptable conversion)	VTIL-Python	J:\My_Projects\VTIL-Python\external\pybind11\include\pybind11\operators.h	115	
Error	C2672	'pybind11::class_<vtil::symbolic::directive::instance>::def': no matching overloaded function found	VTIL-Python	J:\My_Projects\VTIL-Python\external\pybind11\include\pybind11\operators.h	52	
Error	C2893	Failed to specialize function template 'pybind11::class_<vtil::symbolic::directive::instance> &pybind11::class_<vtil::symbolic::directive::instance>::def(const char *,Func &&,const Extra &...)'	VTIL-Python	J:\My_Projects\VTIL-Python\external\pybind11\include\pybind11\operators.h	47	
Error	C2678	binary '*': no operator found which takes a left-hand operand of type 'const L' (or there is no acceptable conversion)	VTIL-Python	J:\My_Projects\VTIL-Python\external\pybind11\include\pybind11\operators.h	117	
Error	C2088	'*': illegal for struct	VTIL-Python	J:\My_Projects\VTIL-Python\external\pybind11\include\pybind11\operators.h	117	

Reproducible example code

No response

@AhmedZero AhmedZero added the triage New bug, unverified label Mar 24, 2022
@Skylion007 Skylion007 added compiler issue and removed triage New bug, unverified labels Mar 24, 2022
@rwgk
Copy link
Collaborator

rwgk commented Mar 24, 2022

Reproducible example code
No response

Could you please provide one, ideally in a PR? Without we have to spend a lot of time guessing.
We have CI coverage for MSVC 2022 C++20, e.g. (random recent example):
https://github.com/pybind/pybind11/runs/5681914694?check_suite_focus=true
So all we need is a reproducer.

@AhmedZero
Copy link
Author

@rwgk
Copy link
Collaborator

rwgk commented Mar 24, 2022

That's a haystack.
What we need is the needle.

@AhmedZero
Copy link
Author

the build is succeeded when I comment on those lines.
AhmedZero/VTIL-Python@f551cff

@rwgk
Copy link
Collaborator

rwgk commented Mar 27, 2022

That helps a lot narrowing down what the issue is.
For easy future reference, it looks like most or all of these cause MSVC 2022 C++20 to fall over:

					//.def( py::self - py::self )
					// .def( py::self | py::self )
					// .def( py::self & py::self )
					// .def( py::self ^ py::self )
					//.def( py::self * py::self )
					//.def( py::self * int64_t() )
					// .def( py::self / py::self )
					// .def( py::self % py::self )

The next step is that someone needs to create a reproducer.

A quick search: we're exercising the operator overloads in:

  • pybind11/tests/test_operator_overloading.cpp — most relevant
  • pybind11/tests/test_sequences_and_iterators.cpp — seems tangential

Those tests are known to work with MSVC 2022 C++20 (GitHub Actions), so something appears to be special about your case, but what?

You have two options:

  1. guess & try adding code to test_operator_overloading.cpp
  2. reduce your code to a minimum that still makes the compiler fall over ("minimal reproducer"), then transfer that to test_operator_overloading.cpp

From past experience, this can take anywhere from 5 minutes to 5 hours, even with a lot of prior knowledge doing such things.

After you have a reproducer that triggers the compiler failure in the GitHub Actions: we will have to find a workaround for the compiler bug (99.99999% certain we're dealing with a compiler bug; MSVC is infamous for those). This can take anywhere from 1 minute to 1 week.

Do you have someone who could help you?

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

No branches or pull requests

3 participants