Skip to content

Document STATIC_ASSERT; add STATIC_ASSERT_EXPR and use it #23627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: blead
Choose a base branch
from

Conversation

khwilliamson
Copy link
Contributor

The STATIC_ASSERT macros are useful and have been stable for long enough to be made API.

This also adds STATIC_ASSERT_EXPR suitable for use in macros. It doesn't achieve parity with the others except on systems where gcc brace groups are used, falling back to less or no checking otherwise. But that's good enough to be useful and any problems will be caught when the code is attempted to be compiled on a brace group platform.

  • This set of changes requires a perldelta entry, which will be furnished

There are now enough items, that sorting is helpful to reading
I think these are useful and stable enough to make public
I found these useful in understanding it
These make things a bit clearer by not putting so much in each macro
This new type of a STATIC_ASSERT is used where an expression can go;
hence potentially in macro expansions.  Since it is compile-time, it
can't be used on arguments that are expressions with side effects, so
can safely be used in macros.

It has limitations however, only reaching full parity when gcc brace
groups are enabled, turning into an ASSUME which is a no-op in the worst
case.

However, most code will get compiled on a platform with gcc brace
groups, and will pass or fail at compile time; so the chances of
something bad actually getting into the field are minimal.
This makes sure that the argument whose pointer is being passed has the
correct size to be settable by the called element.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant