Paul Eggert <[EMAIL PROTECTED]> writes:
> Autoconf shouldn't keep track of which functions have pointers in
> their signatures. There are too many of them, with too many variants
> on different hosts, and the variants mutate too rapidly.
I agree.
> We can keep AC_CHECK_FUNC around for backward compatibility, and
> encourage people to switch to AC_CHECK_FUNCTION.
The backward-compatible AC_CHECK_FUNC should also work with BPs as
per my second suggestion (try once with return type `char' and again
with return type `char *' if `-fbounded-pointers' is in CFLAGS).
We shouldn't require users to convert configure.in as a prerequisite
for using BPs.
> In order to prevent accidentally mixing BP and non-BP functions,
> gcc prepends "__BP_" to the name of every function that has a
> pointer in its arg-type/return-type signature.
>
> I don't see how this can work in general. A function can access data
> via other means, e.g. external pointers
As for external pointers, it works as well as C++ typesafe linkage,
which also mangles only function names. It makes sense to prefix data
names as well to close that hole. (Does anyone know the historical
rationale for C++ not mangling data names?) So far, I have had not
had trouble with mismatched data for using BPs on textutils &
fileutils or for bootstrapping gcc.
> ... or casting its arguments to
> pointers. So even if its signature contains no pointers, a function
> can still be incompatible with code compiled with the other regime.
Gcc does the right thing. If a function accepts an integer arg but is
passed a pointer, gcc strips the bounds from the pointer and passes a
single word, and issues a warning. If a function accepts a pointer
arg but is passed an integer, gcc adds NULL bounds and again warns.
The problem I'm addressing is when a declaration doesn't match a
definition. Say foo is declared without a prototype `extern int
foo()', but elsewhere defined as `int foo (char *)'. The use will
refer to it as `foo' but the definition will define `__BP_foo',
leading to a linktime error. The fix is to add an accurate prototype
decl for foo. Alternatively, say foo is declared accurately with
a prototype and the using file is compiled with BPs, but the defining
file is not. The use will refer to `__BP_foo', but the definition
will be `foo'. Again, you get a linktime error.
Greg