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 MSVC coverage for Constant and UnitSymbol #363

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

chiphogg
Copy link
Contributor

@chiphogg chiphogg commented Dec 18, 2024

Some comments on the vcpkg PR to upgrade Au to 0.4.0 made me suspicious
that we lacked coverage here. I added a test case, and sure enough, it
broke.

What's happening here is that MSVC is being extremely persnickety
about what we pass to a static_assert. We are passing a function
parameter, which in the general case might be a runtime value;
hence, inappropriate for static_assert.

What MSVC doesn't know is that OtherUnit is a monovalue type, so it
can only ever have one possible value, and therefore that value is
knowable at compile time. That said, since it is a monovalue type,
that means that it's safe to replace the instance u with an ad hoc
construction of the type name, OtherUnit{}. This appeases MSVC.

Helps #364: we'll go over every other static_assert before closing.

Some comments on the vcpkg PR to upgrade Au to 0.4.0 made me suspicious
that we lacked coverage here.  I'm going to add it and see if it breaks.
@chiphogg chiphogg added the release notes: ⚙️ repo PR affecting the way the repository works label Dec 18, 2024
@chiphogg chiphogg requested a review from timhirsh December 18, 2024 14:51
@chiphogg chiphogg marked this pull request as ready for review December 18, 2024 14:51
@chiphogg chiphogg requested a review from a team as a code owner December 18, 2024 14:51
@chiphogg chiphogg merged commit 30e0b27 into main Dec 18, 2024
14 checks passed
@chiphogg chiphogg deleted the chiphogg/cover-constants-symbols-msvc branch December 18, 2024 16:01
chiphogg added a commit that referenced this pull request Dec 18, 2024
I went through every `static_assert` in our C++ files, and added MSVC
test coverage for any that looked like they might be vulnerable to the
same error as in #363.

I added these test cases one at a time, so I could tell which ones
failed.

- The `is_known_to_be_less_than_one` "bug" never actually failed,
  whether I called it directly or indirectly.  I'm leaving the tests in
  place, and I "fixed" it anyway because it made the function body more
  stylistically consistent.

- The `inverse_as`/`inverse_in` bug was indeed another instance of this
  problem.  Now we have coverage and a fix.

Fixes #364.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: ⚙️ repo PR affecting the way the repository works
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants