lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> On 2 January 2015 at 12:35, Roberto Ierusalimschy
> <> wrote:
> > This code has been like this for more than 10 years. Why did you wait for
> > 'rc3' to complain?  :-)
> I only just tried adding -pedantic to MYCFLAGS

We have been using -pedantic all along :-) (But we could not find any
way that removes the warning *and* is valid C, because the whole stuff
is not valid C.)

> > This hack is as undefined in C99 as ours,
> The rationale from POSIX
> (

I saw it (after your mention). That "rationale" is indeed a
non-rationale, concluding that the API should not have been designed the
way it is:

    Due to the problem noted here, a future version may either add a new
    function to return function pointers, or the current interface may
    be deprecated in favor of two new functions: one that returns data
    pointers and the other that returns function pointers.

(The non-conformance of the (not-)suggested solution is not only a
theoretical issue.  Because the assignment from 'dlsym' is to a pointer
to void*, not to lua_Cfunction, a compiler could safely assume that
the assignment could not change the value of 'f' and optimize code
accordingly.  We already had that kind of problem in the past, with
float-variable addresses being converted to pointers to ints.)

-- Roberto