Menu

Commit [r13011]  Maximize  Restore  History

Fix the GCC 14+ errors in tools/asql, and a real sqgetdbs/long bug with them

Reported building r13010: "Error compiling infx.ec" in tools/asql, with no
detail. The detail is in tools/asql/infx.warn, which 4glpc writes instead of
sending to stdout - that is why none of this showed up in the build log.

Three things in there are warnings under GCC 13 and errors from GCC 14 on:

- jtypes.c calls isxdigit, isspace, isalnum, isdigit, isalpha, ispunct and
tolower with only <unistd.h> included. Added <ctype.h>. There are two copies
of this file, tools/asql and tools/adbload2, and both had it.
- infx.4gl defines execute_select_free() and asql_explain() with no return
type. Both are used as int by their callers (execute.c) and declared int in
generic.c, so they are now written that way. asql_explain also had no return
statement at all while execute.c does "raffected=asql_explain(...)", so it
now returns 0 rather than whatever was in the register.
- sqgetdbs() is exported by the ESQL/C library but declared in none of the
shipped headers, so it was an implicit declaration. Added a prototype, the
same one added to lib/libsql/esqlc/esql.ec in r13002.

Declaring sqgetdbs then exposed a genuine bug at three of its four call sites.
It writes an int through its first argument, but they pass &ndbs where ndbs is
a 4gl integer, ie a long: on LP64 the top four bytes are left uninitialised and
the database count comes back wrong. The fourth call site already worked around
this with an int temporary; the other three now do the same.

Verified by rebuilding tools/asql: infx.warn goes from 10 GCC-14-fatal
diagnostics to 0, and a full clean build still passes.

Note for whoever picks this up next: a sweep of the .warn files this build
writes shows the same class of problem still present in tools/adbload2 (22),
glade/ide (about 26 across several files) and tools/asql/runforms (3) - all of
them functions called without a visible prototype. They are next in line to
stop a GCC 15 build.

mikeaubury 2026-08-27

changed /aubit4glsrc/trunk/tools/adbload2/jtypes.c
changed /aubit4glsrc/trunk/tools/asql/infx.4gl
changed /aubit4glsrc/trunk/tools/asql/jtypes.c
/aubit4glsrc/trunk/tools/adbload2/jtypes.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/tools/asql/infx.4gl Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/tools/asql/jtypes.c Diff Switch to side-by-side view
Loading...