jacobwilliams / json-fortran

A Modern Fortran JSON API
https://jacobwilliams.github.io/json-fortran/
Other
332 stars 83 forks source link

Some possible non-standard issues #510

Closed urbanjost closed 2 years ago

urbanjost commented 2 years ago

Well, gfortran at least is not producing errors; but pretty sure these need a second look. passing CK_'' to a 1-character argument is definitely non-standard; and I have seen several compilers not complain about intent clashes; but I might be wrong about the INTENT(IN) options being changed in all the cases; but a couple are definitely being changed. Not sure why I am not getting any warning from gfortran even with the debug flags on, so might be misreading something(?) but you might want to check.


 There are several places where a null string is passed to 
a 1-character parameter; CK_''. For example

   call add_to_path(start_array//trim(adjustl(istr))//end_array,CK_'')

And there are several places where p is intent(in) but appears to
be changed

  subroutine json_value_rename(json,p,name)
  subroutine wrap_json_value_rename(json,p,name)
  subroutine json_add_member_by_path(json,me,path,p,found,was_created)
  subroutine wrap_json_add_member_by_path(json,me,path,p,found,was_created)
  subroutine json_file_add_object(me,path,p,found,was_created)
  subroutine wrap_json_file_add_object(me,path,p,found,was_created)
  recursive subroutine sll_push_node(node,key,value,pointer)
jacobwilliams commented 2 years ago

Thank you! I will take a look.

jacobwilliams commented 2 years ago

I believe intent(in) for pointer arguments just means that the pointer isn't reassigned. It doesn't mean that the contents aren't changed.

urbanjost commented 2 years ago

Explains why I didn't get a warning message from gfortran/ifort. I got messages from a tool we were evaluating and thought I would pass them on; I tend to not need pointers very often so did not know that. Thanks for looking; I will close this then.