[Bug 276738] clang: static_assert conflicts with -std=c++98 -pedantic-errors

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 31 Jan 2024 09:41:01 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276738

Warner Losh <imp@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |imp@FreeBSD.org

--- Comment #4 from Warner Losh <imp@FreeBSD.org> ---
For C, there's certain features that we try to make available in a compatible
way to old standards (eg __restrict to compile it away). I think the logic
here's not right for old C++ standards.

So the trouble is that llvm's
/usr/include/c++/v1/__config
#    define static_assert(...) _Static_assert(__VA_ARGS__)
when compiling for < C++11 (at least that's my reading of it, it's a twisty
maze so it may be in a branch not taken. That's the only place I could see any
redirection that would be affected by the #undef in the example.

sys/cdefs.h defines _Static_assert in an old-school C way for C++ < C++11, so
this feature is visible, but badly implemented for C++.

I suspect that both from reading this code and the #undef in the example means
we should simply not define _Static_assert for C++ at all. The compiler will
either implement it or not, depending on its wishes and give an error if not.
assert.h already tries to do the right thing by not defining it for C++ at all.

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