[PATCH] tst-getdents64.c: Mark as UNSUPPORTED when compiled with Clang

Andrew Pinski pinskia@gmail.com
Wed Dec 18 01:47:38 GMT 2024


On Tue, Dec 17, 2024 at 5:38 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Since Clang doesn't support variable length array in structure:
>
> ./sysdeps/unix/sysv/linux/tst-getdents64.c:118:18: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
>   118 |             char buffer[buffer_size];
>       |                  ^
>
> Mark tst-getdents64.c as UNSUPPORTED when compiled with Clang.

Looking through the history of this testcase, the buffer_size here
used to be a constant but was changed to a VLA inside a struct when
testing with different sizes (42d6270439e). I suspect the testcase
should really be using a static size and have a different function for
each of the sizes under test instead of the VLA. This way it is not
disabled for clang and it might actually be testing what it should be
testing. Since with the VLA, the allocation of the VLA will happen
dynamically inside the loop rather than what the test was trying to
test of not going over the buffer.

Thanks,
Andrew Pinski

>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  sysdeps/unix/sysv/linux/tst-getdents64.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/sysdeps/unix/sysv/linux/tst-getdents64.c b/sysdeps/unix/sysv/linux/tst-getdents64.c
> index ba66d49a2e..c68499f3c7 100644
> --- a/sysdeps/unix/sysv/linux/tst-getdents64.c
> +++ b/sysdeps/unix/sysv/linux/tst-getdents64.c
> @@ -16,6 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>
> +#ifndef __clang__
>  #include <dirent.h>
>  #include <errno.h>
>  #include <fcntl.h>
> @@ -187,3 +188,12 @@ do_test (void)
>  }
>
>  #include <support/test-driver.c>
> +#else
> +#include <support/test-driver.h>
> +
> +int
> +main (void)
> +{
> +  return EXIT_UNSUPPORTED;
> +}
> +#endif
> --
> 2.47.1
>


More information about the Libc-alpha mailing list