Skip to content

CWG3185 [decl.pre] static_assertion-declarations should not be name-declarations #894

Description

@YexuanXiao

Full name of submitter: Yexuan Xiao

Reference (section label): [decl.pre]

Link to reflector thread (if any):

Issue description: In the current wording, block-declaration includes static_assertion-declarations, and name-declarations include block-declaration, while [module.interface] considers all name-declarations as eligible to be declared as export. Therefore, static_assert-declarations are allowed to be declared as export.

Suggested resolution:

Activity

  1. changed the title [-][decl.pre] static_assertion-declarations should not be named-declarations[/-] [+][decl.pre] static_assertion-declarations should not be name-declarations[/+] on Apr 28, 2026
  2. jensmaurer commented on May 2, 2026

    @jensmaurer
    Member
  3. changed the title [-][decl.pre] static_assertion-declarations should not be name-declarations[/-] [+]CWG3185 [decl.pre] static_assertion-declarations should not be name-declarations[/+] on May 2, 2026
  4. term-est commented on Jun 19, 2026

    @term-est
    Member

    linkage-specification: is in the form of:
    extern unevaluated-string name-declaration

    This has the side effect that:

    extern "C" consteval { };
    extern "C" static_assert(true);    
    extern "C" [[fumo]];
    extern "C" namespace reimu = std;
    extern "C" ;

    is well-formed according to our grammar, and no rule appears to make them ill-formed; the linkage semantics just have nothing meaningful to apply to.

    For consistency (and also because extern static_assert is equally bonkers as export static_assert), we should make these ill-formed as well.

    GCC and Clang are compliant, while MSVC and EDG rejects extern "C" [[attribute]]. externing a consteval block works on GCC 16.1 as it has reflection support.

    Proposed resolution for the export also makes export asm-declaration ill-formed, but I am not certain if extern asm-declaration should also be made ill-formed.

    Not sure whether this should be a new issue or considered as part of this one. Let me know if this needs to be its own issue and we don't consider the usecases above as NAD. If so I can open up a new issue for restricting the linkage-specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions