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

false positive warnings about noreturn functions "returning" #1348

Open
infrastation opened this issue Sep 7, 2024 · 0 comments
Open

false positive warnings about noreturn functions "returning" #1348

infrastation opened this issue Sep 7, 2024 · 0 comments

Comments

@infrastation
Copy link
Member

SunOS unstable10s 5.10 Generic_150400-17 sun4v sparc SUNW,SPARC-Enterprise-T5220
cc: Studio 12.5 Sun C 5.14 SunOS_sparc 2016/05/31

I was making a seemingly quick test of the current master branch, and it turned out the build matrix fails because of warnings, for example:

"./gencode.c", line 482: function "bpf_error" marked as not returning, might return (E_FUNC_NO_RET_RET)
"optimize.c", line 2409: function "opt_error" marked as not returning, might return (E_FUNC_NO_RET_RET)
"optimize.c", line 2915: function "conv_error" marked as not returning, might return (E_FUNC_NO_RET_RET)
"./can_set_rfmon_test.c", line 95: function "error" marked as not returning, might return (E_FUNC_NO_RET_RET)

At first I tried adding a pair of diagnostic control macros for E_FUNC_NO_RET_RET, but then realised that pretty much every PCAP_NORETURN function needed it. Then I considered disabling the warning for the particular compiler, but that did not seem to be a good idea. Then I tried #define PCAP_UNREACHABLE while(1); and #define PCAP_UNREACHABLE abort(); for Sun C, but neither had any effect. The latter looked entirely strange, so I looked into /usr/include/iso/stdlib_iso.h, which contains roughly the following:

#if defined(__STDC__)
extern void abort(void) __NORETURN;
#else
extern void abort();
#endif

It seemed that __STDC__ was not defined, but adding the following to the source quickly proved that __STDC__ is in fact defined:

#ifdef __STDC__
#error "__STDC__ defined"
#endif

Furthermore, adding -D__STDC__ to a direct invocation of the compiler had no effect, so the problem seems to be that for some reason the compiler disregards the noreturn attribute in standard headers. The same stands for libpcap-1.10 branch, but I do not understand yet how I missed this regression before and after the 1.10.5 build tests.

This is currently breaking build matrix on Solaris 10 using Sun C 5.14, using GCC works as expected.

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

No branches or pull requests

1 participant