Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flex fails to compile on UBI8 image with LLVM15+ #578

Open
a7marchesini opened this issue Aug 11, 2023 · 1 comment
Open

Flex fails to compile on UBI8 image with LLVM15+ #578

a7marchesini opened this issue Aug 11, 2023 · 1 comment

Comments

@a7marchesini
Copy link

When compiling flex using LLVM 15 or 16 (built from source, although I'm guessing an install from dnf would present the same issue) on the docker image for UBI8, flex fails to compile due to the following error:

misc.c:664:14: warning: call to undeclared function 'reallocarray'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        new_array = reallocarray(array, (size_t) size, element_size);
                    ^
misc.c:664:12: error: incompatible integer to pointer conversion assigning to 'void *' from 'int' [-Wint-conversion]
        new_array = reallocarray(array, (size_t) size, element_size);

The use of reallocarray itself is not the problem, rather it's the fact that the function is undeclared and thus the compiler assumes the return type is int. The problem appears to be here (flexdef.h):

#ifndef HAVE_REALLOCARRAY
void *reallocarray(void *, size_t, size_t);
#endif

If you look at the other uses of HAVE_REALLOCARRAY:

#if HAVE_REALLOCARRAY
	/* reallocarray has built-in overflow detection */
	mem = reallocarray(NULL, (size_t) size, element_size);
#else

this usage is wrong. I believe it should be

#if HAVE_REALLOCARRAY
void *reallocarray(void *, size_t, size_t);
#endif

In fact making this change allows flex to compile once more.

@westes
Copy link
Owner

westes commented Aug 25, 2023

Please submit a pull request with your proposed change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants