Skip to content

Commit 0a416b1

Browse files
committed
Document gfortran compiler error and only enforce standard on newer versions
1 parent 8a5f70f commit 0a416b1

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ matrix:
1313
include:
1414
- os: linux
1515
env: FLIBCPP_DEV=ON GENERATOR=ninja
16-
FLIBCPP_FORTRAN_STD=f2003
1716
addons:
1817
apt:
1918
packages:
@@ -22,18 +21,20 @@ matrix:
2221
- valgrind
2322
- os: linux
2423
env: FLIBCPP_DEV=OFF GENERATOR=make
25-
FLIBCPP_FORTRAN_STD=f2008
24+
FLIBCPP_FORTRAN_STD=f2003
2625
addons:
2726
apt:
2827
packages:
29-
- gfortran
28+
- gcc-8
29+
- gfortran-8
3030
- os: linux
3131
env: FLIBCPP_DEV=OFF GENERATOR=make
3232
FLIBCPP_FORTRAN_STD=f2008
3333
addons:
3434
apt:
3535
packages:
36-
- gfortran
36+
- gcc-9
37+
- gfortran-9
3738

3839
# Build phases
3940
before_install:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function(swig_fortran_add_module name)
166166
cxx_std_11
167167
)
168168

169-
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
169+
if (FLIBCPP_FORTRAN_STD AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
170170
# Compile Fortran code with given standard
171171
target_compile_options(${name}
172172
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>:-std=${FLIBCPP_FORTRAN_STD}>

doc/examples.rst

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ applications that operate on large chunks of data. This example demonstrates
3838
the generic version of the :ref:`modules_algorithm_argsort` subroutine by
3939
sorting a native Fortran array of native Fortran types using a native Fortran
4040
subroutine. The only C interaction needed is to create C pointers to the
41-
Fortran array entries and to provide a C-bound comparator that converts those
42-
pointers back to native Fortran pointers.
41+
Fortran array entries and to provide a C-bound comparator that
42+
converts those pointers back to native Fortran pointers. [#c_f_pointer]_
4343

4444
.. literalinclude:: ../example/sort_generic.f90
4545
:linenos:
@@ -60,6 +60,27 @@ provides procedures to:
6060
.. literalinclude:: ../example/example_utils.f90
6161
:linenos:
6262

63+
64+
.. rubric:: Footnotes
65+
66+
.. [#c_f_pointer] Older versions of Gfortran (before GCC-8) fail to compile the
67+
generic sort example because of a bug that incorrectly claims that taking
68+
the C pointer of a scalar Fortran value is a violation of the standard:
69+
70+
.. code-block:: none
71+
72+
../example/sort_generic.f90:84:38:
73+
74+
call c_f_pointer(cptr=rcptr, fptr=rptr)
75+
1
76+
Error: TS 29113/TS 18508: Noninteroperable array FPTR at (1) to
77+
C_F_POINTER: Expression is a noninteroperable derived type
78+
79+
See `this bug report`_ for more details.
80+
81+
.. _this bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84924
82+
83+
6384
.. ############################################################################
6485
.. end of doc/examples.rst
6586
.. ############################################################################

0 commit comments

Comments
 (0)