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

Add overloads for complex multiply to fix clang16 #2892

Merged
merged 8 commits into from
Apr 24, 2023
Merged

Conversation

andrjohns
Copy link
Collaborator

Summary

As discovered over in this cmdstan issue, clang16 has introduced changes to their std::complex implementation that has broken ADL for our complex multiply. This PR adds explicit complex overloads for multiplication so that they're instantiated first during the template resolution.

Both the complex unit tests and the stanc3 complex test models now compile under clang16 with these changes.

Tests

N/A currently, but additional CI is planned to catch these kinds of issues sooner

Side Effects

N/A

Release notes

Updated complex multiplication overloads for clang16 compatibility

Checklist

  • Math issue #(issue number)

  • Copyright holder: Andrew Johnson

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@WardBrian
Copy link
Member

Were you able to confirm it's limited to just operator* (e.g. operator/ etc are still fine?)

@andrjohns
Copy link
Collaborator Author

Were you able to confirm it's limited to just operator* (e.g. operator/ etc are still fine?)

It's not an issue under clang-16, but the Jenkins failure indicates that it's needed for clang-7 now. Strange.

@WardBrian
Copy link
Member

WardBrian commented Apr 21, 2023

Weird. So a model like https://github.com/stan-dev/stanc3/blob/master/test/integration/good/code-gen/complex_numbers/basic_op_param.stan compiled under clang16 with only the changes here, but now CI is complaining for other operators?

@andrjohns
Copy link
Collaborator Author

Yep

@WardBrian
Copy link
Member

Really odd. I don’t know enough about the ADL rules.

It looks like this patch (the original one, at least) fixed the conda build issue. I’m sure adding more manual operator overloads is probably never a bad thing, but I’ll try the final version of this PR before actually pushing go on the conda update

@andrjohns
Copy link
Collaborator Author

@WardBrian turns out the issue here was that the overloads for basic arithmetic with var types just needed to be included earlier, not more complex overloads.

All's passed, so should be good to merge if the feedstock pr also passes

@rok-cesnovar
Copy link
Member

Thanks to both! Should we do a 2.32.1?

@andrjohns
Copy link
Collaborator Author

Thanks to both! Should we do a 2.32.1?

I do think it should be included in a bugfix release rather than waiting for the next full release but I don't have any strong opinions on whether the issue is urgent enough to warrant a bugfix release now, rather than waiting a time and seeing if any other issues come up. @WardBrian what are your thoughts?

@WardBrian
Copy link
Member

I can manually include the patch for conda, so it’s not strictly necessary from my end for it to be released as a patch. It would probably be nice, though.

I propose waiting a few more days to see if anything else comes up in either case.

Copy link
Member

@WardBrian WardBrian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Thanks for jumping on this @andrjohns

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

Successfully merging this pull request may close these issues.

4 participants