fortran: Fix TEAM_NUMBER intrinsic for -fcoarray=single and -fcoarray=lib [PR126777].
fortran: Corrects TEAM_NUMBER intrinsic behavior with -fcoarray=single and -fcoarray=lib.
Two defects related to the TEAM_NUMBER intrinsic in Fortran coarrays have been fixed, stemming from work on PR126777. First, when using -fcoarray=single, conv_intrinsic_team_number incorrectly returned the team handle instead of -1 for the initial team; this is now corrected to always return -1 in this mode. Second, when using -fcoarray=lib with -lcaf_single, the _gfortran_caf_team_number function would dereference a null team handle, causing a segfault; this is now fixed to handle null handles correctly, treating them as the current team. Documentation and a new test case are also updated.
In Details
fortran: [PR126777] Fix TEAM_NUMBER under -fcoarray=single and lib
This commit resolves two issues affecting the TEAM_NUMBER intrinsic, discovered during the fix for PR126777:
1. **-fcoarray=single behavior**: The conv_intrinsic_team_number function incorrectly returned the team handle itself as the team number when -fcoarray=single was used. In this mode, FORM TEAM is a no-op, and GET_TEAM() folds to a null team type, resulting in a return value of 0 instead of the expected -1 for the initial team. The fix ensures that -1 is always returned for the initial team in `-fcoarray=s…
- TEAM_NUMBER
- A Fortran coarray intrinsic function that returns the team number (an integer identifier) of a specified team. When called without arguments, it returns the number of the current team.
- -fcoarray=single
- A GCC compiler flag that enables Fortran coarray features but restricts them to a single image (process). In this mode, many coarray operations that involve inter-image communication become no-ops or are simplified.
- -fcoarray=lib
- A GCC compiler flag that enables Fortran coarray features using an external library for communication, typically one that supports distributed memory or shared memory communication across multiple images.
- libcaf_single
- A specific library implementation for Fortran coarrays, likely a single-image implementation that provides the necessary runtime support when compiling with
-fcoarray=lib. - intrinsic function
- A function that is built into the programming language and available for use without explicit user definition. Fortran has many intrinsic functions for mathematical operations, array manipulation, and coarray programming.
- transformational function
- A category of Fortran intrinsic functions, particularly for coarrays, that may change the state or structure of the program or data, unlike inquiry functions which only return information.
- inquiry function
- A category of Fortran intrinsic functions that return information about data or program state without modifying it. For example,
SIZE()orLBOUND(). - PR126777
- A problem report number in GCC's bug tracking system, indicating a specific issue that has been addressed by this commit.