Repository navigation
Fix interval - #18
Open
bourdin wants to merge 1 commit into
Open
Fix interval#18bourdin wants to merge 1 commit into
bourdin wants to merge 1 commit into
Conversation
- left_open and right_open were passed by reference to basic_set_interval, which takes them by value, so all intervals were open. - Absent optional arguments were referenced, because .and. does not short circuit. This crashed test_basic when built with fpm. - The initialization of a_left and a_right implied save, so a closed end remained closed in subsequent calls.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three bugs in
interval(basic_intervalinsrc/sets.f90):left_openandright_openwere passed byreference to
basic_set_interval, which takesints by value, so SymEnginereceived an address. The interface now declares them with
value.present(left_open) .and. .not. left_open. Fortran does not short-circuit.and., so absent arguments were referenced. With fpm's default debug flags,test_basicsegfaults there. With CMake it happened to work.integer(c_int) :: a_left = 1, a_right = 1impliessave, so once a call set an end to closed, later callskept it closed. The variables are now initialized at each call.
The default, when the optional arguments are omitted, is unchanged: both ends
are open.
Testing
test_basicnow checks the intervals it creates, e.g. thatinterval(1, 2, left_open=.true., right_open=.false.)is(1, 2]. Without thefix, the new assertions fail with CMake, and
test_basiccrashes with fpm.With the fix,
test_basicpasses in both (gfortran 16, macOS).🤖 Generated with Claude Code