Skip to content

fix -Wextra-semi warning when BOOST_SML_CFG_DISABLE_MIN_SIZE is set (#519)#672

Merged
kris-jusiak merged 1 commit into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-519-wextra-semi-zero-size-array
May 24, 2026
Merged

fix -Wextra-semi warning when BOOST_SML_CFG_DISABLE_MIN_SIZE is set (#519)#672
kris-jusiak merged 1 commit into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-519-wextra-semi-zero-size-array

Conversation

@PavelGuzenfeld
Copy link
Copy Markdown
Contributor

Problem

When BOOST_SML_CFG_DISABLE_MIN_SIZE is defined, __BOOST_SML_ZERO_SIZE_ARRAY expands to nothing. The ten call sites in struct bodies all end with a semicolon:

struct pool_type_impl {
    __BOOST_SML_ZERO_SIZE_ARRAY(byte);   // expands to bare ';'
    ...
};

The preprocessed output contains a bare ; inside a struct definition. Clang 14+ (and any build with -Werror -Wextra-semi) rejects this with:

error: extra ';' after member declaration [-Werror,-Wextra-semi]

Fix

Expand the empty branches to static_assert(true) instead of nothing:

#define __BOOST_SML_ZERO_SIZE_ARRAY(...) static_assert(true)

static_assert(true); is a well-formed member-declaration in C++17, has no run-time effect, and consumes the trailing semicolon so no extra ; appears in the struct body. Applied consistently to all four compiler branches (Clang, GCC, MSVC, IAR) that previously produced the empty expansion.

Verification

g++ -std=c++17 -DBOOST_SML_CFG_DISABLE_MIN_SIZE -Wextra-semi -Werror ...

Compiles cleanly. Full test suite passes with no regressions.

Fixes #519.

@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-519-wextra-semi-zero-size-array branch 2 times, most recently from 8bfba91 to c6f50b2 Compare May 23, 2026 22:18
…oost-ext#519)

When BOOST_SML_CFG_DISABLE_MIN_SIZE is defined, __BOOST_SML_ZERO_SIZE_ARRAY
expanded to nothing.  The ten call sites in struct bodies all end with a
semicolon:

  __BOOST_SML_ZERO_SIZE_ARRAY(byte);

so the preprocessed output contained a bare ';' inside a struct definition.
Clang 14+ (and any build using -Werror -Wextra-semi) rejected this with
'extra ';' after member declaration'.

Fix: expand the empty branches to 'static_assert(true)' instead of nothing.
'static_assert(true);' is a well-formed member-declaration in C++17 and has
no run-time effect, but it consumes the trailing semicolon so no extra ';'
appears in the struct body.  Applied consistently to all four compiler
branches (Clang, GCC, MSVC, IAR) that previously produced the empty expansion.

Fixes boost-ext#519.
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-519-wextra-semi-zero-size-array branch from 7325e1f to 000c4fe Compare May 24, 2026 15:43
@kris-jusiak kris-jusiak merged commit 93100ab into boost-ext:master May 24, 2026
5 checks passed
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.

Clang -Wextra-semi warning with -DBOOST_SML_CFG_DISABLE_MIN_SIZE

2 participants