Page MenuHomeFreeBSD

cdefs.h __generic: avoid gcc -Wunused-value
ClosedPublic

Authored by rlibby on Jul 1 2024, 4:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 15, 1:21 AM
Unknown Object (File)
Thu, Nov 14, 10:32 PM
Unknown Object (File)
Mon, Oct 21, 2:54 PM
Unknown Object (File)
Oct 17 2024, 5:23 PM
Unknown Object (File)
Oct 1 2024, 4:05 AM
Unknown Object (File)
Sep 23 2024, 8:13 PM
Unknown Object (File)
Sep 22 2024, 4:17 PM
Unknown Object (File)
Sep 22 2024, 3:45 PM
Subscribers

Details

Summary

Fixup after
9d2f97981755 <sys/cdefs.h>: Decay expression passed to fallback version of __generic()

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rlibby requested review of this revision.Jul 1 2024, 4:48 PM

Seems fine... what compilers / build env hits this?

In D45825#1044894, @imp wrote:

Seems fine... what compilers / build env hits this?

CROSS_TOOLCHAIN=amd64-gcc13 make buildworld produces about 120 warnings like this one:

gcc13/usr/src/freebsd/amd64.amd64/bin/ln/ln.o.meta:/usr/src/freebsd/bin/ln/ln.c:248:26: warning: left-hand operand of comma expression has no effect [-Wunused-value]
This revision is now accepted and ready to land.Jul 1 2024, 5:28 PM
In D45825#1044894, @imp wrote:

Seems fine... what compilers / build env hits this?

CROSS_TOOLCHAIN=amd64-gcc13 make buildworld produces about 120 warnings like this one:

gcc13/usr/src/freebsd/amd64.amd64/bin/ln/ln.o.meta:/usr/src/freebsd/bin/ln/ln.c:248:26: warning: left-hand operand of comma expression has no effect [-Wunused-value]

Ok. So non c11 env? Would has_extension be a better test so _Generic is used more often?

But either way, what's there is a good fix snd questions like above are for znother day

In D45825#1044906, @imp wrote:

Ok. So non c11 env?

I see. Yeah, it looks like we are compiling userspace (or ln.c anyway...) with -std=gnu99 (probably from share/mk/bsd.sys.mk?). IIRC they are mostly using __generic indirectly through include/libgen.h (dirname/basename compat stuff).

Would has_extension be a better test so _Generic is used more often?

Unsure. Is there a different extension to look for than what's there on line 242? But after some quick experiments, it seems __has_extension(c_generic_selections) is false for gcc13 with any -std and is also false for clang with -std=gnu99, so I'm not actually sure where it's useful.

This revision was automatically updated to reflect the committed changes.

Oh, didn't hit submit before, though this doesn't affect the commit

In D45825#1044906, @imp wrote:

Ok. So non c11 env?

I see. Yeah, it looks like we are compiling userspace (or ln.c anyway...) with -std=gnu99 (probably from share/mk/bsd.sys.mk?). IIRC they are mostly using __generic indirectly through include/libgen.h (dirname/basename compat stuff).

Ah, I need to switch to c11 as the default for everything... Oh, wait, no, that might be a too large a bite to take.

Would has_extension be a better test so _Generic is used more often?

Unsure. Is there a different extension to look for than what's there on line 242? But after some quick experiments, it seems __has_extension(c_generic_selections) is false for gcc13 with any -std and is also false for clang with -std=gnu99, so I'm not actually sure where it's useful.

Ah, so there's not an easy way to do what I'd hoped.... This is the next best thing and I approve. Thanks for fixing it.