Skip to content

[windows] gcc 15 hotfix: use non-default initializer for compile_command_t #1147

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

Merged
merged 1 commit into from
May 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/fpm_compile_commands.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,34 @@ module fpm_compile_commands

end type compile_command_table_t

interface compile_command_t
module procedure cct_new
end interface compile_command_t

contains

!> Override default initializer (GCC 15 bug)
type(compile_command_t) function cct_new(directory,arguments,file) result(cct)
character(len=*), intent(in) :: directory,file
character(len=*), optional, intent(in) :: arguments(:)

integer :: i,n

cct%directory = string_t(trim(directory))
cct%file = string_t(trim(file))

if (present(arguments)) then
n = size(arguments)
else
n = 0
endif
allocate(cct%arguments(n))
do i=1,n
cct%arguments(i) = string_t(trim(arguments(i)))
end do

end function cct_new

!> Cleanup compile command
elemental subroutine compile_command_destroy(self)

Expand Down Expand Up @@ -281,10 +307,9 @@ subroutine cct_register(self, command, target_os, error)
! Fallback: use last argument if not found
if (len_trim(source_file)==0) source_file = trim(args(n))

! Fill in the compile_command_t
cmd = compile_command_t(directory = string_t(cwd), &
arguments = [(string_t(trim(args(i))), i=1,n)], &
file = string_t(source_file))
! Fill in the compile_command_t.
! Use non-default initializer due to gcc 15 bug
cmd = compile_command_t(cwd, args, source_file)

! Add it to the structure
!$omp critical (command_update)
Expand Down
Loading