Skip to content

Conversation

@jameskermode
Copy link

@jameskermode jameskermode commented Dec 18, 2025

User description

Summary

Fixes bugs introduced by merge commit add07a6 when resolving conflicts between the -fdefault-integer-8 fix and the issue jameskermode#306 fix.

Changes

  1. Lines 1072, 1208: Restore integer(c_int) for handle arrays in _write_array_getset_item and _write_array_len methods. The merge incorrectly used plain integer which breaks -fdefault-integer-8.

  2. Lines 887-888: Remove erroneous dummy_this declaration for module-level arrays. The issue Module-level allocatable arrays fail with dimension mismatch after reallocation jameskermode/f90wrap#306 fix removed dummy_this from the subroutine signature but the merge kept the variable declaration, causing compilation errors.

Test plan

  • All tests pass locally with make test

🤖 Generated with Claude Code


PR Type

Bug fix


Description

  • Restore integer(c_int) type for handle arrays in _write_array_getset_item and _write_array_len methods

  • Remove erroneous dummy_this declaration for module-level arrays

  • Fix merge conflict resolution errors from commit add07a6


Diagram Walkthrough

flowchart LR
  A["Merge Conflict<br/>add07a6"] -->|"Incorrect resolution"| B["Bug: plain integer<br/>instead of integer(c_int)"]
  A -->|"Incomplete fix"| C["Bug: dummy_this<br/>declaration remains"]
  B -->|"Fix lines 1072, 1208"| D["Restore integer(c_int)<br/>for handle arrays"]
  C -->|"Fix lines 887-888"| E["Remove dummy_this<br/>for module-level arrays"]
  D --> F["Correct compilation<br/>with -fdefault-integer-8"]
  E --> F
Loading

File Walkthrough

Relevant files
Bug fix
f90wrapgen.py
Fix merge conflict type and declaration errors                     

f90wrap/f90wrapgen.py

  • Removed erroneous dummy_this declaration for module-level arrays in
    _write_sc_array_wrapper method (lines 887-888)
  • Restored integer(c_int) type annotation for handle array parameters in
    _write_array_getset_item method (line 1072)
  • Restored integer(c_int) type annotation for handle array parameters in
    _write_array_len method (line 1208)
  • Added clarifying comment explaining module-level arrays do not need
    dummy_this declaration per issue Module-level allocatable arrays fail with dimension mismatch after reallocation jameskermode/f90wrap#306
+3/-4     

Rykath and others added 8 commits December 15, 2025 15:48
'quip_regression' left out as it has it's own workflow
…dles

When compiling with -fdefault-integer-8, bare integer becomes 8 bytes.
The handle arrays (e.g., this(4)) were declared as integer, meaning
4 x 8 = 32 bytes with -fdefault-integer-8, but sizeof_fortran_t was
calculated assuming 4-byte integers (4 x 4 = 16 bytes).

This mismatch caused segfaults when using transfer() to convert between
pointer types and integer arrays.

Fix by using integer(c_int) for all handle arrays, which remains 4 bytes
regardless of -fdefault-integer-8. This ensures consistent size between
wrapper generation time and runtime.

Changes:
- transform.py: Set wrapper_type to 'integer(c_int)' for derived type args
- f90wrapgen.py: Use integer(c_int) for handle arrays in:
  - visit_Procedure (derived type arguments)
  - _write_sc_array_wrapper (this and dummy_this)
  - _write_array_getset_item (this and item handles)
  - _write_array_len (this handle)
  - _write_scalar_wrapper (this and derived type element handles)
- Add 'use, intrinsic :: iso_c_binding, only: c_int' where needed

Fixes the default_i8 example test.
The errorbinding example was added to the test suite in PR #320 but was
missing the required tests.py and tests_pkg.py files, causing CI to fail.
Remove f2py_string_input and issue299_directc_nested_functions from test
suite until they are fixed:
- f2py_string_input: undefined symbol string_in_array_ (linking issue)
- issue299_directc_nested_functions: types.py shadows Python stdlib types module
The merge commit add07a6 introduced bugs when resolving conflicts
between the -fdefault-integer-8 fix and the issue #306 fix:

1. Lines 1072, 1208: Restore integer(c_int) for handle arrays in
   _write_array_getset_item and _write_array_len methods. The merge
   incorrectly used plain 'integer' which breaks -fdefault-integer-8.

2. Lines 887-888: Remove erroneous dummy_this declaration for
   module-level arrays. The issue #306 fix removed dummy_this from
   the subroutine signature but the merge kept the variable declaration,
   causing compilation errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@qodo-code-review
Copy link

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add iso_c_binding import and implicit none

In the get/set item subroutine, add use, intrinsic :: iso_c_binding, only :
c_int and implicit none before integer(c_int) declarations to ensure c_int is
defined.

f90wrap/f90wrapgen.py [1070-1071]

+self.write("use, intrinsic :: iso_c_binding, only : c_int")
+self.write("implicit none")
 if this is not None:
     self.write("integer(c_int), intent(in) :: %s(%d)" % (this, sizeof_fortran_t))
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The PR changes a parameter type to integer(c_int) but fails to add the necessary use, intrinsic :: iso_c_binding, only : c_int statement, which would cause the generated Fortran code to fail compilation.

High
Import c_int in length wrapper

In the array-length wrapper subroutine, add use, intrinsic :: iso_c_binding,
only : c_int and implicit none before integer(c_int) declarations to ensure the
Fortran code compiles.

f90wrap/f90wrapgen.py [1206-1207]

+self.write("use, intrinsic :: iso_c_binding, only : c_int")
+self.write("implicit none")
 if this is not None:
     self.write("integer(c_int), intent(in) :: %s(%d)" % (this, sizeof_fortran_t))
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The PR changes a parameter type to integer(c_int) but fails to add the necessary use, intrinsic :: iso_c_binding, only : c_int statement, which would cause the generated Fortran code to fail compilation.

High
  • More

@krystophny krystophny force-pushed the fix/default-i8-segfault branch from add07a6 to 61d88fa Compare December 18, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants