Bug 280210 - '#include <stdatomic.h>' fails when -std=c99 and -pedantic-errors options are specified (found on the multimedia/librist port)
Summary: '#include <stdatomic.h>' fails when -std=c99 and -pedantic-errors options are...
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Warner Losh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-09 18:38 UTC by Yuri Victorovich
Modified: 2024-11-11 21:30 UTC (History)
3 users (show)

See Also:


Attachments
test.shar (836 bytes, text/plain)
2024-07-09 18:38 UTC, Yuri Victorovich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2024-07-09 18:38:55 UTC
Created attachment 251956 [details]
test.shar

When the C file with a single include is compiled with 'cc -std=c99 -pedantic-errors test.c' - it fails:



$ sh run.sh
In file included from test.c:1:
/usr/include/stdatomic.h:385:10: error: member reference base type '_Bool' is not a structure or union
  385 |         return (atomic_exchange_explicit(&__object->__flag, 1, __order));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdatomic.h:303:39: note: expanded from macro 'atomic_exchange_explicit'
  303 |         ((void)(order), __sync_swap(&(object)->__val, desired))
      |                                      ~~~~~~~~^ ~~~~~
/usr/include/stdatomic.h:392:2: error: member reference base type '_Bool' is not a structure or union
  392 |         atomic_store_explicit(&__object->__flag, 0, __order);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdatomic.h:334:9: note: expanded from macro 'atomic_store_explicit'
  334 |         ((void)atomic_exchange_explicit(object, desired, order))
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdatomic.h:303:39: note: expanded from macro 'atomic_exchange_explicit'
  303 |         ((void)(order), __sync_swap(&(object)->__val, desired))
      |                                      ~~~~~~~~^ ~~~~~
2 errors generated.
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2024-07-09 18:40:24 UTC
The problem started happening ~2024-06-22.
Comment 2 Konstantin Belousov freebsd_committer freebsd_triage 2024-07-09 21:25:15 UTC
stdatomic.h is the C11 feature.
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2024-07-09 21:48:24 UTC
(In reply to Konstantin Belousov from comment #2)

Then maybe there should be a check for this with a graceful error message.
Comment 4 Konstantin Belousov freebsd_committer freebsd_triage 2024-07-09 22:30:39 UTC
The feature is C11, but the error is self-inflicting: code is compiled in
pedantic mode + gnu99.  Otherwise, it would just work.
Comment 5 Warner Losh freebsd_committer freebsd_triage 2024-07-12 17:35:01 UTC
There's no graceful way to check for this.
You've asked for non-standard things in the C99 environment, so you may not be able to enable all error messages possible, even if it did used to work... As the compilers are updated for newer standards, they may produce new errors for older system...

It's interesting that it's visible on this port. I'll take a look, but it may need to be tweaked how it builds.
Comment 6 Warner Losh freebsd_committer freebsd_triage 2024-07-12 17:37:14 UTC
I'm a little surprised it's trying to compile c99, though, given it's meson.build file:
        default_options: ['c_std=c11', 'warning_level=3', 'libdir=lib'],
Comment 7 Warner Losh freebsd_committer freebsd_triage 2024-07-12 17:39:58 UTC
(In reply to Warner Losh from comment #6)
oh, I see that was the "fix"....
Comment 8 Mark Johnston freebsd_committer freebsd_triage 2024-11-11 21:30:03 UTC
Closing this based on the above discussion.  Please feel free to re-open if that makes sense.