Bug 260251 - static_assert not defined
Summary: static_assert not defined
Status: Closed DUPLICATE of bug 255290
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-standards (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-06 09:14 UTC by Simon Ser
Modified: 2024-02-15 02:27 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Ser 2021-12-06 09:14:08 UTC
static_assert isn't defined in <assert.h> even though it's in the C11 standard. See C11 standard (ISO/IEC 9899:2011) section 7.2 Diagnostics <assert.h> (p: 186-187).

- Example failure: https://builds.sr.ht/~emersion/job/643193
- Reference: https://en.cppreference.com/w/c/language/_Static_assert

Suggested fix: remove !defined(__cplusplus) here:

https://github.com/freebsd/freebsd-src/blob/9c612a5d0af17021abc6e1bb2a8baa5a4c97d05f/include/assert.h#L72
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2021-12-06 11:18:50 UTC
C and C++ are different languages.  You are using C standard to request C++
feature that is explicitly disallowed by C++ standard:

from ISO/IEC 14882:2017(E)

22.3.1 Header <cassert> synopsis
[cassert.syn]
#define assert(E) see below
1 The contents are the same as the C standard library header <assert.h>,
except that a macro named static_assert is not defined.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2021-12-06 11:38:29 UTC
wlroots itself doesn't use C++, so 14.0-CURRENT was already fixed. https://www.freebsd.org/releases/14.0R/schedule/ hasn't been populated yet, so -RELEASE is at least 1 year away.

On older versions one can do something like

  #if defined(__FreeBSD__) && __FreeBSD__ < 14
  #undef _POSIX_C_SOURCE
  #endif

or

  #ifdef __FreeBSD__
  #include <osreldate.h>
  # if __FreeBSD_version < 1400014
  #undef _POSIX_C_SOURCE
  # endif
  #endif

*** This bug has been marked as a duplicate of bug 255290 ***
Comment 3 Simon Ser 2021-12-06 11:51:16 UTC
Oh sorry I misread the conditional. Indeed it seems like a dup of 255290.
Comment 4 measrasy 2024-02-15 02:27:36 UTC
MARKED AS SPAM