Compiler Warnings Audit & Resolution Roadmap
Date: 2025-11-05
Compiler: gfortran with -Wall -Wextra -pedantic -Wunused-variable -Wuninitialized
Total Warnings: ~120+
Risk Classification
🔴 CRITICAL (Requires Careful Surgery)
These need sophisticated implementation changes - DO NOT bulk fix
- src/clipboard/clipboard_module.f90:40 - 1MB stack buffer
- Issue:
character(len=1000000) :: bufferallocates 1MB on stack - Risk: Stack overflow crashes
- Solution: Redesign to use ALLOCATABLE array
- Status: 🔖 BOOKMARKED for manual surgery
- Issue:
🟡 LOW RISK (Straightforward Fixes)
Category: Format/Standards Issues (3 warnings)
-
src/commands/command_handler_module.f90:2352 - Intrinsic shadow
- Issue:
function getpid()shadows intrinsic - Fix: Rename to
get_process_id()or add explicit INTRINSIC declaration - Lines: 2352
- Issue:
-
src/workspace/file_tree_module.f90:253 - Character truncation
- Issue: Assignment truncates 1024 chars to 512
- Fix: Increase destination buffer size or truncate explicitly
- Lines: 253
-
src/workspace/file_tree_module.f90:525 - GNU extension
- Issue: Missing positive width after L descriptor in format
- Fix: Use proper format:
(A,A,A,L1,A,L1) - Lines: 525
🟢 SAFE BULK FIXES
Category A: Unused Local Variables (~60 warnings)
These are safe to remove - no function signature changes
src/clipboard/yank_stack_module.f90 (1)
- Line 49:
new_entries- unused allocatable array
src/clipboard/clipboard_module.f90 (1)
- Line 41:
n_read- unused integer
src/workspace/file_tree_renderer_module.f90 (3)
- Line 116:
i- unused loop variable - Line 116:
prefix_len- unused integer - Line 22:
visible_items- unused integer
src/workspace/file_tree_module.f90 (2)
- Line 611:
prev- unused pointer - Line 151:
i- unused integer
src/terminal/renderer_module.f90 (5)
- Line 69:
buffer_pos- unused integer - Line 68:
ch- unused character - Line 69:
col- unused integer - Line 69:
line_start_pos- unused integer
src/ui/help_display_module.f90 (1)
- Line 101:
section_start- unused integer
src/ui/search_prompt_module.f90 (3)
- Line 21:
use_regex- unused module variable (PRIVATE) - Line 32:
ios- unused integer - Line 31:
options_str- unused character
src/ui/replace_prompt_module.f90 (5)
- Line 133:
should_continue- unused logical - Line 22:
found- unused logical - Line 23:
found_col- unused integer - Line 23:
found_line- unused integer - Line 20:
ios- unused integer
src/ui/goto_prompt_module.f90 (4)
- Line 22:
col_str- unused allocatable string - Line 20:
colon_pos- unused integer - Line 18:
ios- unused integer - Line 22:
line_str- unused allocatable string
src/commands/command_handler_module.f90 (~35+ unused local variables)
- Line 3906:
status- unused integer - Line 3568:
in_word- unused logical - Line 3494:
in_word- unused logical (duplicate name different function) - Line 2527:
is_alt_click- unused logical - Line 2294:
error_msg- unused character(1024) - Line 2295:
has_write_permission- unused logical - Line 2292:
temp_unit- unused integer - Line 1577:
cursors_before- unused integer - (~27 more throughout the file)
Category B: Unused Dummy Arguments (~15 warnings)
Safe to remove, but changes function signatures - check call sites
src/terminal/input_handler_module.f90 (1)
- Line 419:
handle_alt_modified_key()parameterfirst_charunused
src/terminal/renderer_module.f90 (1)
- Line 943:
render_single_pane()parameterbufferunused
src/commands/command_handler_module.f90 (~13 warnings)
- Line 3453:
extend_selection_page_up()parameterline_countunused - Line 3295:
extend_selection_up()parameterline_countunused - Line 3199:
add_cursor_above()parameterbufferunused - (~10 more throughout the file)
Category C: Dead Code (~2 warnings)
Safe to remove - unused functions
src/terminal/renderer_module.f90 (1)
- Line 200:
render_line()- defined but never called
src/ui/help_display_module.f90 (1)
- Line 261:
display_section()- defined but never called
Resolution Strategy
Phase 1: Safe Bulk Fixes (Category A)
- Remove unused local variables
- No signature changes, minimal risk
- Can be done file-by-file systematically
- Estimated: 60 simple deletions
Phase 2: Function Signature Fixes (Category B)
- Remove unused dummy arguments
- Must verify call sites (use compiler to check)
- Compiler will catch any mistakes
- Estimated: 15 parameter removals + call site updates
Phase 3: Dead Code Removal (Category C)
- Delete unused functions
- Verify no indirect calls (callbacks, etc.)
- Estimated: 2 function deletions
Phase 4: Low-Risk Fixes (🟡)
- Fix intrinsic shadow (rename)
- Fix character truncation (increase buffer)
- Fix format descriptor (add width)
- Estimated: 3 targeted fixes
Phase 5: BOOKMARKED for Surgery (🔴)
- Redesign clipboard buffer to use ALLOCATABLE
- Requires careful testing of clipboard operations
- Status: Deferred for manual implementation
Verification Plan
After each phase:
make clean
FC=gfortran make dev 2>&1 | tee /tmp/gfortran_warnings.log
grep -i warning /tmp/gfortran_warnings.log | wc -l
Final target: 0 warnings (except bookmarked items)
Notes
- All fixes preserve functionality
- Compiler errors will catch any mistakes in signature changes
- No automated sed/awk scripts - manual edits only
- Bookmark items require design discussion before implementation
View source
| 1 | # Compiler Warnings Audit & Resolution Roadmap |
| 2 | |
| 3 | **Date:** 2025-11-05 |
| 4 | **Compiler:** gfortran with `-Wall -Wextra -pedantic -Wunused-variable -Wuninitialized` |
| 5 | **Total Warnings:** ~120+ |
| 6 | |
| 7 | --- |
| 8 | |
| 9 | ## Risk Classification |
| 10 | |
| 11 | ### 🔴 CRITICAL (Requires Careful Surgery) |
| 12 | **These need sophisticated implementation changes - DO NOT bulk fix** |
| 13 | |
| 14 | 1. **src/clipboard/clipboard_module.f90:40** - 1MB stack buffer |
| 15 | - **Issue:** `character(len=1000000) :: buffer` allocates 1MB on stack |
| 16 | - **Risk:** Stack overflow crashes |
| 17 | - **Solution:** Redesign to use ALLOCATABLE array |
| 18 | - **Status:** 🔖 BOOKMARKED for manual surgery |
| 19 | |
| 20 | --- |
| 21 | |
| 22 | ## 🟡 LOW RISK (Straightforward Fixes) |
| 23 | |
| 24 | ### Category: Format/Standards Issues (3 warnings) |
| 25 | |
| 26 | 2. **src/commands/command_handler_module.f90:2352** - Intrinsic shadow |
| 27 | - **Issue:** `function getpid()` shadows intrinsic |
| 28 | - **Fix:** Rename to `get_process_id()` or add explicit INTRINSIC declaration |
| 29 | - **Lines:** 2352 |
| 30 | |
| 31 | 3. **src/workspace/file_tree_module.f90:253** - Character truncation |
| 32 | - **Issue:** Assignment truncates 1024 chars to 512 |
| 33 | - **Fix:** Increase destination buffer size or truncate explicitly |
| 34 | - **Lines:** 253 |
| 35 | |
| 36 | 4. **src/workspace/file_tree_module.f90:525** - GNU extension |
| 37 | - **Issue:** Missing positive width after L descriptor in format |
| 38 | - **Fix:** Use proper format: `(A,A,A,L1,A,L1)` |
| 39 | - **Lines:** 525 |
| 40 | |
| 41 | --- |
| 42 | |
| 43 | ## 🟢 SAFE BULK FIXES |
| 44 | |
| 45 | ### Category A: Unused Local Variables (~60 warnings) |
| 46 | **These are safe to remove - no function signature changes** |
| 47 | |
| 48 | #### src/clipboard/yank_stack_module.f90 (1) |
| 49 | - Line 49: `new_entries` - unused allocatable array |
| 50 | |
| 51 | #### src/clipboard/clipboard_module.f90 (1) |
| 52 | - Line 41: `n_read` - unused integer |
| 53 | |
| 54 | #### src/workspace/file_tree_renderer_module.f90 (3) |
| 55 | - Line 116: `i` - unused loop variable |
| 56 | - Line 116: `prefix_len` - unused integer |
| 57 | - Line 22: `visible_items` - unused integer |
| 58 | |
| 59 | #### src/workspace/file_tree_module.f90 (2) |
| 60 | - Line 611: `prev` - unused pointer |
| 61 | - Line 151: `i` - unused integer |
| 62 | |
| 63 | #### src/terminal/renderer_module.f90 (5) |
| 64 | - Line 69: `buffer_pos` - unused integer |
| 65 | - Line 68: `ch` - unused character |
| 66 | - Line 69: `col` - unused integer |
| 67 | - Line 69: `line_start_pos` - unused integer |
| 68 | |
| 69 | #### src/ui/help_display_module.f90 (1) |
| 70 | - Line 101: `section_start` - unused integer |
| 71 | |
| 72 | #### src/ui/search_prompt_module.f90 (3) |
| 73 | - Line 21: `use_regex` - unused module variable (PRIVATE) |
| 74 | - Line 32: `ios` - unused integer |
| 75 | - Line 31: `options_str` - unused character |
| 76 | |
| 77 | #### src/ui/replace_prompt_module.f90 (5) |
| 78 | - Line 133: `should_continue` - unused logical |
| 79 | - Line 22: `found` - unused logical |
| 80 | - Line 23: `found_col` - unused integer |
| 81 | - Line 23: `found_line` - unused integer |
| 82 | - Line 20: `ios` - unused integer |
| 83 | |
| 84 | #### src/ui/goto_prompt_module.f90 (4) |
| 85 | - Line 22: `col_str` - unused allocatable string |
| 86 | - Line 20: `colon_pos` - unused integer |
| 87 | - Line 18: `ios` - unused integer |
| 88 | - Line 22: `line_str` - unused allocatable string |
| 89 | |
| 90 | #### src/commands/command_handler_module.f90 (~35+ unused local variables) |
| 91 | - Line 3906: `status` - unused integer |
| 92 | - Line 3568: `in_word` - unused logical |
| 93 | - Line 3494: `in_word` - unused logical (duplicate name different function) |
| 94 | - Line 2527: `is_alt_click` - unused logical |
| 95 | - Line 2294: `error_msg` - unused character(1024) |
| 96 | - Line 2295: `has_write_permission` - unused logical |
| 97 | - Line 2292: `temp_unit` - unused integer |
| 98 | - Line 1577: `cursors_before` - unused integer |
| 99 | - *(~27 more throughout the file)* |
| 100 | |
| 101 | --- |
| 102 | |
| 103 | ### Category B: Unused Dummy Arguments (~15 warnings) |
| 104 | **Safe to remove, but changes function signatures - check call sites** |
| 105 | |
| 106 | #### src/terminal/input_handler_module.f90 (1) |
| 107 | - Line 419: `handle_alt_modified_key()` parameter `first_char` unused |
| 108 | |
| 109 | #### src/terminal/renderer_module.f90 (1) |
| 110 | - Line 943: `render_single_pane()` parameter `buffer` unused |
| 111 | |
| 112 | #### src/commands/command_handler_module.f90 (~13 warnings) |
| 113 | - Line 3453: `extend_selection_page_up()` parameter `line_count` unused |
| 114 | - Line 3295: `extend_selection_up()` parameter `line_count` unused |
| 115 | - Line 3199: `add_cursor_above()` parameter `buffer` unused |
| 116 | - *(~10 more throughout the file)* |
| 117 | |
| 118 | --- |
| 119 | |
| 120 | ### Category C: Dead Code (~2 warnings) |
| 121 | **Safe to remove - unused functions** |
| 122 | |
| 123 | #### src/terminal/renderer_module.f90 (1) |
| 124 | - Line 200: `render_line()` - defined but never called |
| 125 | |
| 126 | #### src/ui/help_display_module.f90 (1) |
| 127 | - Line 261: `display_section()` - defined but never called |
| 128 | |
| 129 | --- |
| 130 | |
| 131 | ## Resolution Strategy |
| 132 | |
| 133 | ### Phase 1: Safe Bulk Fixes (Category A) |
| 134 | - Remove unused local variables |
| 135 | - No signature changes, minimal risk |
| 136 | - Can be done file-by-file systematically |
| 137 | - **Estimated:** 60 simple deletions |
| 138 | |
| 139 | ### Phase 2: Function Signature Fixes (Category B) |
| 140 | - Remove unused dummy arguments |
| 141 | - Must verify call sites (use compiler to check) |
| 142 | - Compiler will catch any mistakes |
| 143 | - **Estimated:** 15 parameter removals + call site updates |
| 144 | |
| 145 | ### Phase 3: Dead Code Removal (Category C) |
| 146 | - Delete unused functions |
| 147 | - Verify no indirect calls (callbacks, etc.) |
| 148 | - **Estimated:** 2 function deletions |
| 149 | |
| 150 | ### Phase 4: Low-Risk Fixes (🟡) |
| 151 | - Fix intrinsic shadow (rename) |
| 152 | - Fix character truncation (increase buffer) |
| 153 | - Fix format descriptor (add width) |
| 154 | - **Estimated:** 3 targeted fixes |
| 155 | |
| 156 | ### Phase 5: BOOKMARKED for Surgery (🔴) |
| 157 | - Redesign clipboard buffer to use ALLOCATABLE |
| 158 | - Requires careful testing of clipboard operations |
| 159 | - **Status:** Deferred for manual implementation |
| 160 | |
| 161 | --- |
| 162 | |
| 163 | ## Verification Plan |
| 164 | |
| 165 | After each phase: |
| 166 | ```bash |
| 167 | make clean |
| 168 | FC=gfortran make dev 2>&1 | tee /tmp/gfortran_warnings.log |
| 169 | grep -i warning /tmp/gfortran_warnings.log | wc -l |
| 170 | ``` |
| 171 | |
| 172 | Final target: **0 warnings** (except bookmarked items) |
| 173 | |
| 174 | --- |
| 175 | |
| 176 | ## Notes |
| 177 | |
| 178 | - All fixes preserve functionality |
| 179 | - Compiler errors will catch any mistakes in signature changes |
| 180 | - No automated sed/awk scripts - manual edits only |
| 181 | - Bookmark items require design discussion before implementation |