Skip to content

Conversation

@chiphogg
Copy link
Member

The "complex to real" test was based on some assumptions about how
std::complex worked which I had never verified. It turns out that
whether or not we permit certain conversions, they may not even be
possible. For example: you can't actually construct a
std::complex<float> from a std::complex<int>, even though you can of
course construct a float from an int!

Therefore, we delete all irrelevant aspects of the test case, and focus
it down to its core: that std::complex<float> to float is forbidden.

The "negative ratio, unsigned destination" test will begin to fail for
an unrelated reason, with our new and more carefully designed
construction policy. uint8_t has a max value of 255, and int8_t a
max value of 127. We will now prevent assigning the former to the
latter because the risk of overflow is too high. (The max
non-overflowing value is 127, which is smaller than our threshold of
2147.)

Here, the fix is to just use 16-bit integers.

Helps #349.

The "complex to real" test was based on some assumptions about how
`std::complex` worked which I had never verified.  It turns out that
whether or not we _permit_ certain conversions, they may not even be
_possible_.  For example: you can't actually construct a
`std::complex<float>` from a `std::complex<int>`, even though you can of
course construct a `float` from an `int`!

Therefore, we delete all irrelevant aspects of the test case, and focus
it down to its core: that `std::complex<float>` to `float` is forbidden.

The "negative ratio, unsigned destination" test will begin to fail for
an unrelated reason, with our new and more carefully designed
construction policy.  `uint8_t` has a max value of 255, and `int8_t` a
max value of 127.  We will now prevent assigning the former to the
latter because the risk of overflow is too high.  (The max
non-overflowing value is 127, which is smaller than our threshold of
2147.)

Here, the fix is to just use 16-bit integers.

Helps #349.
@chiphogg chiphogg merged commit 0c41f72 into main Jul 18, 2025
14 checks passed
@chiphogg chiphogg deleted the chiphogg/tweak-invalid-tests#349 branch July 18, 2025 21:51
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.

3 participants