This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 120a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2026-05-31


3185. Exporting a static_assert-declaration

Section: 10.2  [module.interface]     Status: review     Submitter: Yexuan Xiao     Date: 2026-04-28     Liaison: EWG

(From submission #894.)

Consider:

  export static_assert(true);

This is syntactically valid, because export is followed by a name-declaration per 10.2 [module.interface] paragraph 1. One option for name-declaration is block-declaration (see 9.1 [dcl.pre] paragraph 1). One option for block-declaration is static_assert-declaration.

However, the additional export is entirely meaningless. Similar concerns apply to consteval-block-declaration and empty-declaration.

Proposed resolution (May, 2026):

Change in 10.2 [module.interface] paragraph 1 as follows:

An export-declaration shall inhabit a namespace scope and appear in the purview of a module interface unit. An export-declaration shall not appear directly or indirectly within an unnamed namespace or a private-module-fragment. An export-declaration has the declarative effects of its name-declaration, declaration-seq (if any), or module-import-declaration. The name-declaration of an export-declaration shall not neither The declaration-seq of an export-declaration shall not contain an export-declaration or module-import-declaration.

Additional notes (2026-05-30)

Forwarded to EWG with paper issue #2802 for considering the design direction.