Skip to content

fix: rename reserved __BOOST_SML_* macros and args__ identifiers (issue #220)#683

Open
PavelGuzenfeld wants to merge 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-220-reserved-identifiers
Open

fix: rename reserved __BOOST_SML_* macros and args__ identifiers (issue #220)#683
PavelGuzenfeld wants to merge 2 commits into
boost-ext:masterfrom
PavelGuzenfeld:fix/issue-220-reserved-identifiers

Conversation

@PavelGuzenfeld
Copy link
Copy Markdown
Contributor

Problem

The C++ standard (ISO C++ [lex.name]) reserves all identifiers that begin with two consecutive underscores (__) for any use by the implementation. Using them in a library header is undefined behaviour.

SML's include/boost/sml.hpp contained seven such macros and two reserved C++ identifiers:

Before After
__BOOST_SML_UNUSED BOOST_SML_DETAIL_UNUSED
__BOOST_SML_VT_INIT BOOST_SML_DETAIL_VT_INIT
__BOOST_SML_ZERO_SIZE_ARRAY BOOST_SML_DETAIL_ZERO_SIZE_ARRAY
__BOOST_SML_ZERO_SIZE_ARRAY_CREATE BOOST_SML_DETAIL_ZERO_SIZE_ARRAY_CREATE
__BOOST_SML_TEMPLATE_KEYWORD BOOST_SML_DETAIL_TEMPLATE_KEYWORD
__BOOST_SML_REQUIRES BOOST_SML_DETAIL_REQUIRES
__BOOST_SML_DEFINED_HAS_BUILTIN BOOST_SML_DETAIL_DEFINED_HAS_BUILTIN
args1__ (C++ identifier) args1_
args__ (C++ identifier) args_

__has_builtin is intentionally left unchanged — SML defines it only on platforms where the compiler doesn't provide it, and the name must match the compiler convention.

Notes

  • No behaviour change. This is a pure mechanical rename.
  • All user-facing macros (BOOST_SML_CFG_*, BOOST_SML_CREATE_*, BOOST_SML_NAMESPACE_*) are unaffected.
  • No user code should be using __BOOST_SML_* macros (the double-underscore prefix explicitly signals implementation detail).
  • A #undef BOOST_SML_DETAIL_REQUIRES is added to the cleanup section at the end of the header; the previous __BOOST_SML_REQUIRES was missing its #undef.

Closes #220

@PavelGuzenfeld PavelGuzenfeld marked this pull request as draft May 25, 2026 11:26
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-220-reserved-identifiers branch from 082cc98 to 4b8c3e6 Compare May 25, 2026 19:17
@PavelGuzenfeld
Copy link
Copy Markdown
Contributor Author

Branch rebased onto current master (which merged PRs #672, #673, #676, #677, #678, #679).

Conflict resolution: PR #678 added a doc comment above the operator, template that still used __BOOST_SML_REQUIRES; the rebase preserves that comment and uses the renamed BOOST_SML_DETAIL_REQUIRES.

Additional fix: include/boost/sml/utility/dispatch_table.hpp also used __BOOST_SML_REQUIRES. This PR now re-defines BOOST_SML_DETAIL_REQUIRES locally in that file (after the #include "boost/sml.hpp") and #undefs it at the end, since sml.hpp #undefs the macro at its close. All 37 test files pass.

@PavelGuzenfeld PavelGuzenfeld marked this pull request as ready for review May 25, 2026 19:21
…t-ext#220)

Identifiers beginning with double-underscore (__) are reserved by the
C++ standard for any use by the implementation (ISO C++ [lex.name]).
Using them in a library header is undefined behaviour.

Renames (no behaviour change):
  __BOOST_SML_UNUSED              -> BOOST_SML_DETAIL_UNUSED
  __BOOST_SML_VT_INIT             -> BOOST_SML_DETAIL_VT_INIT
  __BOOST_SML_ZERO_SIZE_ARRAY     -> BOOST_SML_DETAIL_ZERO_SIZE_ARRAY
  __BOOST_SML_ZERO_SIZE_ARRAY_CREATE -> BOOST_SML_DETAIL_ZERO_SIZE_ARRAY_CREATE
  __BOOST_SML_TEMPLATE_KEYWORD    -> BOOST_SML_DETAIL_TEMPLATE_KEYWORD
  __BOOST_SML_REQUIRES            -> BOOST_SML_DETAIL_REQUIRES
  __BOOST_SML_DEFINED_HAS_BUILTIN -> BOOST_SML_DETAIL_DEFINED_HAS_BUILTIN
  args1__  (internal identifier)  -> args1_
  args__   (internal identifier)  -> args_

The __has_builtin macro is intentionally left unchanged: SML defines it
only to emulate the compiler's own feature-test macro on platforms that
lack it, and the name must match the compiler convention.

A matching #undef BOOST_SML_DETAIL_REQUIRES is added to the cleanup
section at the end of the header (the old __BOOST_SML_REQUIRES was not
previously undef'd).

All public user-facing macros (BOOST_SML_CFG_*, BOOST_SML_CREATE_*,
BOOST_SML_NAMESPACE_*) are unchanged — only implementation-detail macros
are affected.
@PavelGuzenfeld PavelGuzenfeld force-pushed the fix/issue-220-reserved-identifiers branch from fecd811 to 760fe90 Compare May 26, 2026 06:30
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.

Use of reserved identifiers

1 participant