Hi Jerry!
Am 20.05.25 um 05:23 schrieb Jerry D:
On 5/19/25 1:50 PM, Harald Anlauf wrote:
Hi Jerry,
so contrary to what the name of patch claims (pr120049-final.diff),
it fixes only the case of direct use of iso_c_binding, but not the
indirect one thru the other module, which is the reason for the
original ICE and the PR.
So if you want to push the incremental patch now, go ahead.
Cheers,
Harald
Am 18.05.25 um 23:46 schrieb Jerry D:
On 5/18/25 2:34 PM, Jerry D wrote:
On 5/18/25 2:10 PM, Harald Anlauf wrote:
Hi Jerry,
I found 2 corner invalid cases which are silently accepted with
your patch when iso_c_binding is used indirectly:
print *, c_associated(c_loc(val), C_NULL_FUNPTR)
print *, c_associated(C_NULL_FUNPTR, c_loc(val))
These should get rejected, too. Can you see how to catch these, too?
Thanks,
Harald
Yes, will do! I try to think of cases to run through on. This helps.
Thanks,
Jerry
--- snip ---
Attached is the revised patch to fix the additional test cases. I had to
do some trial and error to get the testsuite directives to work the way
they should.
One will notice that the file containing the gtk_sup module is
simplified and gets taken care of with the directives in the specific
tests.
Regression tested on x86_64.
OK for trunk?
No, not yet. It rejects too much (consistently). Consider:
program tests_gtk_sup
use, intrinsic :: iso_c_binding
type(c_ptr), target :: val
type(c_funptr), target :: fptr
print *, c_associated(fptr, C_NULL_FUNPTR)
print *, c_associated(c_loc(val), C_NULL_PTR)
print *, c_associated(C_NULL_PTR, c_loc(val))
print *, c_associated(c_loc(val), C_NULL_FUNPTR) ! invalid
print *, c_associated(C_NULL_FUNPTR, c_loc(val)) ! invalid
end
All tests are rejected, but only the indicated ones should be.
With your latest patch I get:
pr120049-2.f90:5:30:
5 | print *, c_associated(fptr, C_NULL_FUNPTR)
| 1
Error: Argument C_PTR_2 at (1) to C_ASSOCIATED shall have the same type
as C_PTR_1: TYPE(c_funptr) instead of TYPE(c_funptr)
pr120049-2.f90:6:36:
6 | print *, c_associated(c_loc(val), C_NULL_PTR)
| 1
Error: Argument C_PTR_2 at (1) to C_ASSOCIATED shall have the same type
as C_PTR_1: TYPE(c_ptr) instead of TYPE(c_ptr)
pr120049-2.f90:7:36:
7 | print *, c_associated(C_NULL_PTR, c_loc(val))
| 1
Error: Argument C_PTR_2 at (1) to C_ASSOCIATED shall have the same type
as C_PTR_1: TYPE(c_ptr) instead of TYPE(c_ptr)
pr120049-2.f90:8:36:
8 | print *, c_associated(c_loc(val), C_NULL_FUNPTR) ! invalid
| 1
Error: Argument C_PTR_2 at (1) to C_ASSOCIATED shall have the same type
as C_PTR_1: TYPE(c_ptr) instead of TYPE(c_funptr)
pr120049-2.f90:9:39:
9 | print *, c_associated(C_NULL_FUNPTR, c_loc(val)) ! invalid
| 1
Error: Argument C_PTR_2 at (1) to C_ASSOCIATED shall have the same type
as C_PTR_1: TYPE(c_funptr) instead of TYPE(c_ptr)
The first 3 errors make no sense.
Cheers,
Harald
-- Jerry