ShinobuAmasaki / forgex

A Regular Expression Engine written entirely in Fortran
https://shinobuamasaki.github.io/forgex/
MIT License
21 stars 3 forks source link

Minor issues in Debug mode #3

Closed phreeplot closed 2 weeks ago

phreeplot commented 2 weeks ago

Great. Thanks for doing this.

I compiled with ifx (Windows and VS) and gfortran (Ubuntu on WSL) and all went well in Release mode. All tests completed successfully. However, I came across a couple of issues in Debug mode which you may want to address. They are both rather trivial to fix.

nfa_node_m.F90:347-8 !> @note Note that the return value of the size function on an unallocated array is undefined. if (j >= size(self%forward, dim=1) .or. .not. allocated(self%forward)) then You correctly note in the comment above that the SIZE function of an unallocated array is undefined. Compilers treat this differently; gfortran in Debug mode does not like this (with minimal options) and exits with an unallocated error. Best to check for allocation status before doing a SIZE and take appropriate action if unallocated. There may be other SIZE's that need checking.

app_internal_m.f90:208 if (.not. empty_pre) matches_pre = string(1:len_pre) == prefix ifx complains if 1 is greater than the length of string (e.g. for a null string, length is zero) so a preliminary check on this is required here.

ShinobuAmasaki commented 2 weeks ago

Hi.

Thanks to your suggestion, these issues most likely were fixed in commit 17691a159d563d1bcfed3e23eeb96b9e2e9d1dc5 and 72d3abb0667d628b5edbea10711af19f703a9d82 for the procedures used by the API of this library. They have been merged to the main branch. Please try it out with the latest main branch.

In my environment, all tests I ran using the following options passed:

with gfortran v13.2 on Linux and Windows:

-O0 -Wall -g -fcheck=array-temps,bounds,do,mem,pointer,recursion -ffpe-trap=invalid,zero,overflow,underflow

with ifx 2024.0.0 20231017 on Linux:

 -g -O0 -traceback -check all -fpe0 -warn all -debug full -init=snan,arrays -assume protect_parens -standard-semantics

with ifx 2024.0.2 Build 20231213 on Windows:

 /Zi /Od /traceback /check:all /fpe0 /warn:all /debug:full /init:snan,arrays /assume:protect_parens /standard-semantics

In addition, I would like to fix the procedures used by the command line tools soon.

If you have anything else, please feel free to comment.

Thank you!

phreeplot commented 2 weeks ago

Thanks, you have fixed these issues.