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

Fix error in indexing for matrix-to-grid input #8554

Merged
merged 1 commit into from
Jul 25, 2024
Merged

Fix error in indexing for matrix-to-grid input #8554

merged 1 commit into from
Jul 25, 2024

Conversation

seisman
Copy link
Member

@seisman seisman commented Jul 25, 2024

Description of proposed changes

Related to #5294 and #5947 and patches #5947.

S_obj->wesn[XLO] can't be smaller than G_obj->header->wesn[XLO], because at line below:

i0 = (unsigned int)gmt_M_grd_x_to_col (GMT, S_obj->wesn[XLO]+dx, G_obj->header);

The macro is expanded to something like:

(S_obj->wesn[XLO]+dx - G_obj->header->wesn[XLO]) / G_obj->header->inc[GMT_X] - G_obj->header->xy_off

If S_obj->wesn[XLO] < G_obj->header->wesn[XLO], then the result is negative, but i0 is defined as unsigned int on Linux/macOS. Then i0 has a weird positive value, making the for loop below fail.

On Windows, it doesn't have the issue, because openmp_int is defined as int on Windows.

@seisman seisman marked this pull request as ready for review July 25, 2024 15:04
@seisman seisman merged commit 24984c1 into master Jul 25, 2024
15 of 18 checks passed
@seisman seisman deleted the api/matrix branch July 25, 2024 15:05
@seisman seisman added the bug Something isn't working label Jul 25, 2024
@seisman seisman added this to the 6.6.0 milestone Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants