public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114870] New: stddef.h problem with -Wsystem-headers on Fedora 40
@ 2024-04-26 20:46 eggert at cs dot ucla.edu
  0 siblings, 0 replies; only message in thread
From: eggert at cs dot ucla.edu @ 2024-04-26 20:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870

            Bug ID: 114870
           Summary: stddef.h problem with -Wsystem-headers on Fedora 40
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at cs dot ucla.edu
  Target Milestone: ---

Created attachment 58049
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58049&action=edit
fix stddef.h to survive multiple includes, some with __need_size_t etc.

I found this when trying to build GNU diffutils on Fedora 40. This is gcc (GCC)
14.0.1 20240411 (Red Hat 14.0.1-0) on x86-64. Compile the following two-line
program t.c with 'gcc -std=gnu23  -Wsystem-headers -E t.c >t.i':

  #include <stddef.h>
  #include <time.h>

GCC issues the following diagnostics:

  In file included from /usr/include/time.h:29,
                   from t.c:2:
  /usr/lib/gcc/x86_64-redhat-linux/14/include/stddef.h:457:9: warning:
"__STDC_VERSION_STDDEF_H__" redefined
    457 | #define __STDC_VERSION_STDDEF_H__       202311L
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from t.c:1:
  /usr/lib/gcc/x86_64-redhat-linux/14/include/stddef.h:457:9: note: this is the
location of the previous definition
    457 | #define __STDC_VERSION_STDDEF_H__       202311L
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~

It seems that <stddef.h> is not properly protected against multiple includes,
some with __need_size_t and __need_NULL and some without.

The attached patch to stddef.h worked around the problem for me.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-26 20:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26 20:46 [Bug c/114870] New: stddef.h problem with -Wsystem-headers on Fedora 40 eggert at cs dot ucla.edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).