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]: Description of is_fmt_numeric does not match actual behavior #5428

Open
2 of 3 tasks
MaartenBaert opened this issue Nov 3, 2024 · 0 comments
Open
2 of 3 tasks
Labels
triage New bug, unverified

Comments

@MaartenBaert
Copy link
Contributor

Required prerequisites

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

75e48c5

Problem description

The description of is_fmt_numeric states (in comments):

Note that the long double types only participate when long double is actually longer than double (it isn't under MSVC).

However this isn't what actually happens, because std::is_same<double, long double>::value is false even when sizeof(double) == sizeof(long double), as is indeed the case with MSVC on x86_64:
https://godbolt.org/z/xdd135a8T

Likewise, std::is_same<int, long>::value is false even when sizeof(int) == sizeof(long). This is presumably why platform_lookup uses sizeof rather than std::is_same to check type equivalence.

I'm not sure whether the correct solution here is to update the description to match actual behavior, or rather change the behavior to match the description.

Reproducible example code

int main() {
    std::cerr << sizeof(float) << ' ' << detail::is_fmt_numeric<float>::index << std::endl;
    std::cerr << sizeof(double) << ' ' << detail::is_fmt_numeric<double>::index << std::endl;
    std::cerr << sizeof(long double) << ' ' << detail::is_fmt_numeric<long double>::index << std::endl;
};

// expected output:
// 4 9
// 8 10
// 8 10

// actual output:
// 4 9
// 8 10
// 8 11

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

Not a regression

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

No branches or pull requests

1 participant