Closed jschueller closed 1 year ago
See the :open_file_folder: files view, the :scroll:action log or :angel: SARIF report for details.
libclang
Let me reconfirm, this is not VLA, right? If yes, then it is something better retained because it is quite informative and user-friendly.
However, due to the limitation of Clang.jl at the moment, let us compromise as follows.
prima.h
and prima.c
? According to the discussion at Clang.jl, I guess only prima.h
needs modification, right? If yes, let us modify prima.h
only. In addition, add some comment in prima.h
such as
Unlike prima.c, the arrays here do not contain hint sizes. This is because we want to use Clang.jl to generate Julia wrappers, but Clang.jl does not support hint sizes as of 20230916 ( https://github.com/JuliaInterop/Clang.jl/discussions/443 ). Hint sizes will be added once Clang.jl supports ( https://github.com/JuliaInterop/Clang.jl/issues/444 ).
What do you think?
Thanks.
This might be off-topic, but as C compilers always treat arrays as pointers in a function prototype and do not perform any size check, and I don't find any size check in the c wrapper, does it happen on the Fortran side?
This might be off-topic, but as C compilers always treat arrays as pointers in a function prototype and do not perform any size check, and I don't find any size check in the c wrapper, does it happen on the Fortran side?
Hi @Gnimuc ,
The c-binding Fortran subroutines (e.g., prima/c/cobyla_c.f90
) do not do any size check, although the sizes are included in the declaration of the arrays (compilers will not check them).
If we go deeper into the Fortran implementation itself (e.g., prima/fortran/cobyla.f90
), arrays are passed as "assumed-shape arrays". The sizes of those arrays are not included in the declaration but can be extracted from the arrays (I guess they are implemented as structures at a lower level), and the Fortran implementation of PRIMA does check that the sizes of the inputs are correct --- note that it is done manually within the code at runtime, not by the compiler.
Thanks.
I would remove them completely in both .h and .c for consistency, they dont check anything (I think fortran doesnt check much either). Checks can be done easily in the higher level languages though, see how I added asserts in the Python layer.
This might be off-topic, but as C compilers always treat arrays as pointers in a function prototype and do not perform any size check, and I don't find any size check in the c wrapper, does it happen on the Fortran side?
Hi @Gnimuc ,
The c-binding Fortran subroutines (e.g.,
prima/c/cobyla_c.f90
) do not do any size check, although the sizes are included in the declaration of the arrays (compilers will not check them).If we go deeper into the Fortran implementation itself (e.g.,
prima/fortran/cobyla.f90
), arrays are passed as "assumed-shape arrays". The sizes of those arrays are not included in the declaration but can be extracted from the arrays (I guess they are implemented as structures at a lower level), and the Fortran implementation of PRIMA does check that the sizes of the inputs are correct.Thanks.
thanks for the explanation. makes sense to me now.
I would remove them completely in both .h and .c for consistency, they dont check anything (I think fortran doesnt check much either). Checks can be done easily in the higher level languages though, see how I added asserts in the Python layer.
I am a bit hesitant. I was thinking that the sizes were quite informative to users. I did not think about the size check.
So my proposal was to remove those in prima.h
for the moment and restore them when possible. But I do not know the recent common / best practices in C.
If you still think it is better to remove those in prima.c
after rethinking, I will not disagree.
Thanks.
and the Fortran implementation of PRIMA does check that the sizes of the inputs are correct.
note that the check is done manually within the code at runtime, not by the compiler.
yes, lets remove it everywhere
see https://github.com/JuliaInterop/Clang.jl/discussions/443