[Bug 261310] The libgen.h sources use C11-specific features under e.g. -std=gnu99, causing a -Wc11-extensions warning

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 18 Jan 2022 15:43:49 UTC

            Bug ID: 261310
           Summary: The libgen.h sources use C11-specific features under
                    e.g. -std=gnu99, causing a -Wc11-extensions warning
           Product: Base System
           Version: CURRENT
          Hardware: Any
               URL: https://lore.kernel.org/git/patch-1.1-06cc12be94d-2022
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: avarab@gmail.com
                CC: ed@FreeBSD.org, fuz@fuz.su

Created attachment 231131
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=231131&action=edit
"fix" the issue with _Generic() in libgen.h by ignoring -Wc11-extension

The $subject issue was encountered when testing a pre-release of git. I've
submitted a workaround for it in $url.

As noted in $url I think this is a regression in the 2014-era commit by
ed@FreeBSD.org to sys/cdefs.h

Since then the __generic() wrapper for the C11-_Generic() has checked the
__STDC_VERSION__ *or* __has_extension(c_generic_selections). The problem being
that the latter is a way to ask if the compiler supports this at all, and not
whether the current -std=* would emit a warning about it conflicting with the
currently selected C version.

There's probably a less crappy way to solve this, but I can't think of one that
isn't the attached patch. I.e. the issue is that both GCC and Clang don't seem
to have a way to request the C version in effect for the purposes of warnings
being emitted, so we can just quiet the relevant warning. If such a thing
exists I haven't found it.

I'm not sure if FreeBSD still cares about GCC, but if so the added pragma lines
also need duplicated "#pragma GCC...".

You are receiving this mail because:
You are the assignee for the bug.