Bug 473604 - Fix bug472219.c compile failure with Clang 16
Summary: Fix bug472219.c compile failure with Clang 16
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.22 GIT
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-21 15:33 UTC by fanquake
Modified: 2023-08-22 19:36 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
memcheck-fix-bug472219.c-compile-failure-under-Clang.patch (1.34 KB, application/mbox)
2023-08-21 15:33 UTC, fanquake
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fanquake 2023-08-21 15:33:08 UTC
Created attachment 161091 [details]
memcheck-fix-bug472219.c-compile-failure-under-Clang.patch

Compiling memcheck/tests/bug472219.c under clang (16.0.0) currently fails with:

bug472219.c:14:4: error: call to undeclared function 'ppoll'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   ppoll(fds, 2, &timeout, NULL);
   ^
bug472219.c:14:4: note: did you mean 'poll'?
/usr/include/x86_64-linux-gnu/sys/poll.h:54:12: clang -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector  -Wno-format-extra-args -Wno-literal-range -Wno-tautological-constant-out-of-range-compare -Wno-self-assign -Wno-string-plus-int -Wno-uninitialized -Wno-unused-value  -m64    -o err_disable2 err_disable2.o  
note: 'poll' declared here
extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
           ^
1 error generated.

Adding the missing _GNU_SOURCE define (patch attached) fixes the issue.
Comment 1 Mark Wielaard 2023-08-21 16:09:42 UTC
Seeing the same warning (not an error) with gcc 13.2.1:

gcc -DHAVE_CONFIG_H -I. -I../..  -I../.. -I../../include -I../../coregrind -I../../include -I../../VEX/pub -I../../VEX/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -DVGPV_amd64_linux_vanilla=1 -DVGA_SEC_x86=1 -DVGP_SEC_amd64_linux=1   -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector   -m64 -Wno-uninitialized  -MT bug472219-bug472219.o -MD -MP -MF .deps/bug472219-bug472219.Tpo -c -o bug472219-bug472219.o `test -f 'bug472219.c' || echo './'`bug472219.c
bug472219.c: In function ‘main’:
bug472219.c:14:4: warning: implicit declaration of function ‘ppoll’; did you mean ‘poll’? [-Wimplicit-function-declaration]
   14 |    ppoll(fds, 2, &timeout, NULL);
      |    ^~~~~
      |    poll
Comment 2 Paul Floyd 2023-08-22 06:43:45 UTC
Bah. "It worked on my machine".

STANDARDS
     The poll()	function conforms to IEEE Std 1003.1-2001 ("POSIX.1").	The
     ppoll() is	not specified by POSIX.	 The POLLRDHUP flag is not specified
     by	POSIX, but is compatible with Linux and	illumos.
Comment 3 Mark Wielaard 2023-08-22 11:29:05 UTC
I should have added that the proposed fix to #define _GNU_SOURCE before the #include <poll.h> works to get rid of the warning.
Comment 4 Paul Floyd 2023-08-22 19:36:13 UTC
commit bdd5f0bad19eb9544511a9c40241901d34f16781 (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Tue Aug 22 21:35:00 2023 +0200

    Bug 473604 - Fix bug472219.c compile failure with Clang 16