Closed
Description
I did this
Built curl-for-win with gcc for mac (arm64), and this compiler warning happened:
curl/lib/http.c: In function 'Curl_add_custom_headers':
curl/lib/http.c:1528:42: warning: '%s' directive argument is null [-Wformat-overflow=]
1528 | result = Curl_dyn_addf(req, "%s\r\n", compare);
| ^~
https://github.com/curl/curl-for-win/actions/runs/9906570816/job/27368394282#step:3:4688
I expected the following
No warnings.
curl/libcurl version
master f94aa3d
operating system
macOS 14 arm64 GHA runner
Activity
bagder commentedon Jul 19, 2024
That's a silly warning for us since a NULL there is not a problem.
But also: how is it NULL there?
bagder commentedon Aug 2, 2024
I build with gcc 14 locally on my x86_64 debian and this is not a warning I see. Does it only happen on arm64? That seems weird.
How about just silence the (false positive) warning for that compiler + platform combo?
vszakats commentedon Aug 2, 2024
Are you building with cmake/unity=on?
vszakats commentedon Aug 2, 2024
Good question regarding the CPU. There is no Intel gcc test in CI, but could replicate it locally:
cmake:
not minimal, but straight of a curl-for-win with curl + libressl only:
With riscv64 Linux and gcc 14 this warning is not happening.
Instead there is this one, where the code look correct but non-trivial for a compiler to see:
vszakats commentedon Aug 2, 2024
Confirmed this is unity-specific, and thus needs cmake.
bagder commentedon Aug 17, 2024
But we don't see these in any CI do we?
vszakats commentedon Aug 17, 2024
It's on the curl-for-win daily CI run.
Edit: no sorry, not the daily but the other, extended workflow.
bagder commentedon Aug 19, 2024
-Wformat-overflow
is not a warning that we want enabled as it does not help us. It can only bring us false positives:We explicitly never use sprintf and vsprintf in code (they are banned by checksrc).
I will file a PR to remove it.
build: use -Wno-format-overflow
build: use -Wno-format-overflow