git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] sparse: ignore warning from new glibc headers

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Jul 17, 2024, 18:40 UTC
Message-ID
<9bdac465-5f43-42de-9cad-e6c43a5a53cc@ramsayjones.plus.com>
In-Reply-To
<xmqqikx42c42.fsf@gitster.g>
On 17/07/2024 17:54, Junio C Hamano wrote:
Show 16 quoted lines
> Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:
> 
>> With at least glibc 2.39, glibc provides a function declaration that
>> matches with this POSIX interface:
>>
>>     int regexec(const regex_t *restrict preg, const char *restrict string,
>>            size_t nmatch, regmatch_t pmatch[restrict], int eflags);
>>
>> such prototype requires variable-length-array for `pmatch'.
>> ...
>> Thus, sparse reports this error:
>>
>>> ../add-patch.c: note: in included file (through ../git-compat-util.h):
>>> /usr/include/regex.h:682:41: error: undefined identifier '__nmatch'
>>> /usr/include/regex.h:682:41: error: bad constant expression type
>>> /usr/include/regex.h:682:41: error: Variable length array is used.

Yes, I noted this about 2 years ago! If memory serves, it was when the libc6-dev package went from v2.31 to 2.35 (well 2.31-0ubuntu9.9).

As I said at the time, this only affected glibc platforms (so not newlib on cygwin for example) of a certain vintage, so I just added

  SPARSE_FLAGS += -D__STDC_NO_VLA__
to my config.mak file.
Show 5 quoted lines
> I get the same with 
> 
> 	$ sparse --version
> 	v0.6.4-66-g0196afe1
> 

I mentioned this problem to Luc on the sparse mailing list[1] and he produced a patch which 'fixed' the problem in one way, but caused a different problem[2]. Namely, because git passes -Wvla to gcc, it now issues the 'used vla' warnings, which gcc does not because of some '# pragma GCC diagnostic ignored "-Wvla"' which sparse does not honor! :(

So, his patch was not applied in the end.

ATB, Ramsay Jones

The sparse mailing list archive can be found at:
   https://lore.kernel.org/linux-sparse
The messages below were from December 2023 (approx. 20/12/2023)

[1] Message-ID: <6f853a6b-9ac3-4bfd-a968-89d43fbcce2a@ramsayjones.plus.com> [2] Message-ID: <24cb6194-d04d-4c80-bd95-4f7356667884@ramsayjones.plus.com>

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 15 in “sparse: ignore warning from new glibc headers”
  1. sparse: ignore warning from new glibc headersĐoàn Trần Công Danh, Jul 16, 2024
  2. Junio C HamanoJul 17, 2024
  3. Ramsay JonesJul 17, 2024
  4. Junio C HamanoJul 17, 2024
  5. Ramsay JonesJul 17, 2024
  6. Ramsay JonesJul 17, 2024
  7. Junio C HamanoJul 17, 2024
  8. Ramsay JonesJul 18, 2024
  9. Đoàn Trần Công DanhJul 18, 2024
  10. Junio C HamanoJul 18, 2024
  11. Đoàn Trần Công DanhJul 18, 2024
  12. Junio C HamanoJul 18, 2024
  13. Ramsay JonesJul 19, 2024
  14. Johannes SchindelinApr 8, 2025
  15. Junio C HamanoApr 8, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.